3
I have a program too big for here and so I created a fiddle to illustrate my problem.
I want to catch and store in a variable p
, but the alert
is always sending empty. Can help me sff?
HTML
<ul>
<li>1</li>
<li>2</li>
<li class = "middle_item">
<a>
<div id= "box">
<div id= "header">
<p>1234567</p>
</div>
</div>
<div></div>
<div></div>
</a>
</li>
<li>4</li>
<li>5</li>
</ul>
Javascript
var aqui = $("li .middle_item .header").text();
alert(aqui);
That is not the fiddle. the correct fiddle http://jsfiddle.net/ufkoqeu8/6/
– msm.oliveira
@msm.oliveira ah, you changed the question...
– Sergio
@msm.oliveira so this is what you want: http://jsfiddle.net/ufkoqeu8/7/
– Sergio
what a stupid mistake on my part . I got it. I was using . instead of # . That div has id and no class
– msm.oliveira
@msm.oliveira happens to everyone, nice to have another pair of eyes to see sometimes :) Remember that it should be without space here:
li .middle_item
and that the#
is the ID selector.– Sergio
ok. thanks. if you want to update the answer I accept
– msm.oliveira
@msm.oliveira updated the reply and I will delete these comments here later too.
– Sergio