jquery - I want to change the + into - minus when related accordion -
hi want change + - when square clicked please see the js fidddle!
https://jsfiddle.net/vklhfpxt/
$('.work-detail2, .work-detail3').hide(); $('.work-1').addclass('squar-active') $('.work-1').click(function(){ $('.work-1').addclass('squar-active'); $('.work-2,.work-3').removeclass('squar-active'); $('.work-detail1').show(500); $('.work-detail2, .work-detail3').hide(500); }); $('.work-2').click(function(){ $('.work-1,.work-3').removeclass('squar-active'); $('.work-2').addclass('squar-active'); $('.work-detail2').show(500); $('.work-detail1, .work-detail3').hide(500); }); $('.work-3').click(function(){ $('.work-1,.work-2').removeclass('squar-active'); $('.work-3').addclass('squar-active'); $('.work-detail3').show(500); $('.work-detail1, .work-detail2').hide(500); });
i'm assuming there's html happening here within squares. call .innerhtml(); on them:
$document.getelementbyclassname('squar-active').innerhtml = '-';
the "getelementbyclassname()" function , grabs elements class of "squar-active". ".innerhtml" function subsequently changes html inside element whatever defined between parentheses ('as string'). , use same functions change , forth between "+" , "-".
best wishes!
edit:
$('.work-detail2, .work-detail3').hide(); $('.work-1').addclass('square-active') $('.work-1').click(function(){ $('.work-1').addclass('square-active'); $('.work-2,.work-3').removeclass('square-active'); $('.work-2, .work3').addclass('square-inactive'); $('.work-detail1').show(500); $('.work-detail2, .work-detail3').hide(500); }); $('.work-2').click(function(){ $('.work-1,.work-3').removeclass('square-active'); $('.work-1, .work-3').addclass('square-inactive'); $('.work-2').addclass('square-active'); $('.work-detail2').show(500); $('.work-detail1, .work-detail3').hide(500); }); $('.work-3').click(function(){ $('.work-1,.work-2').removeclass('square-active'); $('.work-1, work-2').addclass('square-inactive'); $('.work-3').addclass('square-active'); $('.work-detail3').show(500); $('.work-detail1, .work-detail2').hide(500); }); $document.getelementbyclassname('square-active').innerhtml = '-'; $document.getelementbyclassname('square-inactive').innerhtml = '+';
this how rewrite original script. i'm not proficient jquery, think should help.
Comments
Post a Comment