I'm trying to create a flexible toggle function with jQuery where I take the ID of the item to be toggled as a parameter. the function is triggered by a link which passes the correct ID to the function.
here is the code at the moment:
function boldToggler(itemid){
$(itemid).toggle(function(){
$(itemid).css("font-weight","bold");},
function(){
$(itemid).css("font-weight","normal");});
}
which is triggered by links like this:
<a href="javascript: boldToggler('h1')">toggle style for this item</a>
<a href="javascript: boldToggler('h2')">toggle style for this item</a>
is there a way to get this to work? it would save me writing hundreds of toggle functions!
Any help would be amazing, thanks
togglefunction is deprecated in the latest version of jquery