I know this is a bit silly question, but I still cannot find an answer, perhaps I am searching the keywords are not right.
I hope someone could correct my js expression.
var id = idname;
$('#' + id).hide();
(‘#’ + id) expression has error from console, I’d like to have $(‘#variable‘) what is the right expression $('"#'+xerocon2013'"').
Thanks for someone could put me up
Update,
Sorry guys, I have dollar sign.
the error is
unrecognized expression: #[object HTMLDivElement]
I tested yesterday was fine, but just doesnt work today.. sigh. how odd.
I through my code maybe not right.
I just want to make sure my expression is correct. if there is no error with my expression then would be my code.
codes
<script type="text/javascript">
$(function(){
$(window).bind("load", function () {
var urlHash = window.location.href.split("#")[1];
$('html,body').animate({ scrollTop: $('#' + urlHash).offset().top}, 1000);
});
});
</script>
<style type="text/css">
.space{height:800px;}
#anchor{font-size:25px;height:800px;display:block;}
</style>
<div class="space"></div>
<div id="anchor">This is anchor</a>
Thanks everyone.
So with the error, the issue would be the fact that the hash is not being returned. So if there is no hash, you are looking for an element with $(“#”)
the window.location has a hash property, so there is no reason to split