Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

console.log($('"#'+d+'"'));

In my HTML, I have:

<div id="2013-10-23">
    <h1>5</h1>
    <p>eeeeeeeeeeee</p>
</div>

In the above code, I have one <div> with an id of 2013-10-23, and when getting that id it is throwing this syntax error:

Uncaught Error: Syntax error, unrecognized expression: "#2013-10-23"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
614 views
Welcome To Ask or Share your Answers For Others

1 Answer

try

console.log($("#"+d));

your solution is passing the double quotes as part of the string.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...