Hi ,
I need to know how to pass html element into jquery function.
My sample html code is given below:
<html>
<head>
<script src='../../core/js/jquery-1.4.2.min.js'></script>
<script src='../../core/js/jquery-ui-1.8.1.min.js'></script>
<script src='../../core/js/extensions.js'></script>
<script src='../../core/js/prot-lib.js'></script>
</head>
<body>
<table>
<tr>
<td class='r1'>
<chl class="chl">
<chli class="menu-list">
<li id="s0" class="item" onClick="handle('s0')">NJ</li>
<li id="s1" class="item" onClick="handle('s1')">TX</li>
</chli>
</chl>
</td>
<td class='r1'>
<chl class="chl">
<chli class="menu-list">
<li id="s0" class="item" onClick="handle('s0')">NJ</li>
<li id="s1" class="item" onClick="handle('s1')">TX</li>
</chli>
</chl>
</td>
</tr>
</table>
</body>
</html>
Jquery function is given below:
function handle(id){
var text = $('#'+id).text();
$('#'+id).closest('chl').find('#id').css("color","black").val(text);
}
I want to pass the html element also in handle function. Reason is the above is accessing first element always when i select second list element in html. The li id's are same for both the html elements.
Is there anyway I can pass the html element itself to the function handle() along with id?
Its immediate requirement. Any help appreciated.
Thanks in Advance,
VC