मैं मूल रूप से ऐसा करने की कोशिश कर रहा हूं जो विषय सुझाता है, लेकिन मुझे मेरी चेतावनी में "अपरिभाषित" हो रहा है, और मुझे पूरा यकीन नहीं है कि क्यों। मैं jquery के लिए काफी नया हूँ, इसलिए, शायद मेरे पास सिंटैक्स गलत है, लेकिन यह सुनिश्चित नहीं है कि यहां से कहां जाना है। मैं अपने प्रयासों की दोनों, दोनों उपज "अनिर्धारित" चेतावनी में ...jquery का उपयोग कर चर तत्व में बाल तत्व और स्टोर की एक आईडी प्राप्त करें?
//In my first attempt, I'm trying to get the id of the inner a tag
<ul>
<li id="l1" class="active"><a href="#c1">Samp 1</a></li>
<li id="l2" class=""><a href="#c2">Samp 2</a></li>
<li id="l3" class=""><a href="#c3">Samp 3</a></li>
</ul>
var selected = $(".active).children("a").attr("id");
alert(selected);
//In my second attempt, I'm trying to get the id of the currently selected li
var selected = $(".active").attr("id");
alert(selected);
आप दोहरे उद्धरण चिह्नों वंचित रह जाएंगे। –