Here is the Script i have written to handle it but for some reason + and - swapping is not happening
$('.showCheckbox').click(function(e) {
var dynamicBox = $(this).attr('val');
var collapseSign = $(this).attr('id');
$('#'+dynamicBox).slideToggle();
$('#'+dynamicBox+collapseSign).html(function(_, text){
return text === '+' ? '−' : '+';
});
});
You can find Fiddle here http://jsfiddle.net/7Gt4L/ Please help!
Change:
$('#'+dynamicBox+collapseSign).html(function(_, text){
return text === '+' ? '−' : '+';
});
to:
$('#'+collapseSign).html(function(_, text){
return text === '+' ? '−' : '+';
});
This will use the ID of the collapse sign clicked to change the text.
I believe the collapseSign
portion of your selector should be a string. Otherwise you will be trying to match something similar to #partnerspartnerscollapseSign
, which doesn't exist:
$('.showCheckbox').click(function(e) {
var dynamicBox = $(this).attr('val');
$('#'+dynamicBox).slideToggle();
$('#'+dynamicBox+'collapseSign').html(function(_, text){
return text === '+' ? '−' : '+';
});
});
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.