Why won't this work?
HTML
<a href="#" id="showMore">Before</a>
JS
$('#showMore').click(function() {
$(this).toggle(
function () {
$(this).html('<a href="#">After</a>');},
function () {
$(this).html('<a href="#">Before</a>');
});
});
Why won't this work?
HTML
<a href="#" id="showMore">Before</a>
JS
$('#showMore').click(function() {
$(this).toggle(
function () {
$(this).html('<a href="#">After</a>');},
function () {
$(this).html('<a href="#">Before</a>');
});
});
Not sure what's up with JsFiddle.net, but I can't post a demo.
You're nesting two functions within each other (
.click()
and.toggle()
), and.toggle()
handles aclick
, so that might be causing conflict. Also, usetext()
instead ofhtml()
:HTML:
JavaScript: