i have this pretty simple piece of code where i get a certain id and what im trying to do is to change the element's css. the code looks like this:
<script>
jQuery('.sitePick').click(function(event){
var site = (event.target.href.split("#")[1]); // get the id
console.log(site); // make sure i get the correct id
jQuery('#' + site).css("display" , "block"); //change css
});
</script>
the log prints the correct id of the element, and when i tried t use the same id like this : docuemnt.getElementById(site).style.display = "block"
it worked, but not when using jQuery.
what worries me the most its that even when i passed the id as is ( jQuery("#dummySite") to jQuery it still didn't work..any idea what i'm doing wrong? thx
UPDATE
the value of site is "site_buzzy.com". I am loading jquery right at the beginning of the file, other jquery methods work.the script being loaded after the content.
site, coz generally integers or values starting with integers are known to cause problems. Also, 1. are you loading jQuery, 2. loading the script after loading jQuery, and thirdly, 3. loading the script after the content has been loaded?jQuery('#' + site).show();.jQuery('.sitePick').click(...)is called ? to do so wrap your code with$(function(){ });event.targetandthis:) I was just making a side note btw, i din't downvoted your answer even Jai was correct, it didn't really make senseelement.target,jQuery('#' + site)is notthis