A simple jquery line of code:
if ($j('#page2').length) {
$j('#myPlaceHolder2').html('<button class=\"button3\" type=\"button\">Page II</button>');
}
This works perfectly fine. When I later create a span with id myPlaceHolder2, it displays the button.
Now I need to add an onclick event
onclick=\"javascript: $j('#'+openc).fadeOut('normal', function(){$j('#page2').fadeIn('slow')});openc='page2';\"
To the above .html, as follows
$j('#myPlaceHolder2').html('<button class=\"button3\" type=\"button\" onclick=\"javascript: $j('#'+openc).fadeOut('normal', function(){$j('#page2').fadeIn('slow')});openc='page2';\">Page II</button>');
And all hell breaks loose. I tried escaping each ' with \\ but it breaks my site entirely for some reason. I'm not very familiar with javascript or jquery, only learning as I go, so any indication as to how to get this done would be helfpul, thank you!
Add it with jQuery:
$j('#myPlaceHolder2')
.html('<button class=\"button3\" type=\"button\">Page II</button>')
.find('.button3')
.click(function () {
$j('#'+openc).fadeOut('normal', function(){$j('#page2').fadeIn('slow')});openc='page2';
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.