How to get the text from the div menu and make a bold on click from jquery
I have bind the menu at the run time (i.e .cs file) in the div. When I click on the perticular menu, then those make a bold text from jquery. 开发者_运维技巧Please help. example:
<div><ul><a>code</a></ul></div>
First of all, if that is an accurate portrayal of your mark up, your <a>
tags should not be directly in the <ul>
tags, there should be list item tags <li>
inside the <ul>
s. Additionally, you will want to add a class/id to the <ul>
or surrounding <div>
to aid/specify the jQuery selectors.
That being said here is your markup:
<div id="mylist-wrapper">
<ul>
<li><a hreh="#">Link</a></li>
<li><a hreh="#">Link</a></li>
<li><a hreh="#">Link</a></li>
</ul>
</div>
And the jQuery to go with it:
$('#mylist-wrapper a').click(function(){
$(this).css('font-weight', 'bold');
});
Something like:
$('div ul a').live('click', function() {
$(this).css('font-weight', 'bold');
});
精彩评论