jquery - Append new html with a onclick event -
i have button:
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" name="kontakt" onclick="$(this).min('kontakt');">_</button>
and jquery:
$.fn.min = function(navn) { $('#footermenu').append('<li><button onclick="$(this).test('+navn+');">'+navn+'</button></li>'); }; $.fn.test = function(navn) { alert('something'); };
i can't last alert('something')
display can tell me i'm doing wrong?
it may quotes.
try this:
$('#footermenu').append('<li><button onclick="$(this).test('+"'"+navn+"'"+');">'+navn+'</button></li>');
or way
var clicktxt = '$(this).test("' + navn + '");'; $('#footermenu').append('<li><button onclick="' + clicktxt + '">'+navn+'</button></li>');
Comments
Post a Comment