Find enter button in selected div class

How can I use jquery to recognize this button in a div with the class name "blueheaderbar accordionButton on" and then change the value of the button to "hide it"

<div class="blueheaderbar accordionButton selected" style="margin-top:20px"> <div class="floatleft">abc</div> <div class="floatright"><input class="showhidebtn" type="button" value="Show Outlet" style="margin:6px 16px 0 0; width:86px" /></div> <div class="clear"></div> </div> <div class="blueheaderbar accordionButton" style="margin-top:20px"> <div class="floatleft">abc</div> <div class="floatright"><input class="showhidebtn" type="button" value="Show Outlet" style="margin:6px 16px 0 0; width:86px" /></div> <div class="clear"></div> </div> 
+6
source share
4 answers

I think the answer is:

 $("div.blueheaderbar.selected").find("input").val("hide it"); 
+13
source

"blueheaderbar accordionButton selected" not a "one" class name, but three. CSS selector to select an element with all three classes -

 .blueheaderbar.accordionButton.selected 

(note the absence of spaces!).

So, to find the input inside with jQuery, follow these steps:

 var $input = jQuery(".blueheaderbar.accordionButton.selected input"); 

or

 var $input = jQuery(".blueheaderbar.accordionButton.selected").find("input"); 
+2
source

it will do the trick -

 jQuery(".blueheaderbar.accordionButton.selected").find(".showhidebtn").hide(); 

and for secon div try this

 jQuery(".blueheaderbar.accordionButton").find(".showhidebtn").hide(); 

you can try this way also -

 jQuery(".blueheaderbar.accordionButton.selected > .showhidebtn").hide(); 

Working demo

+2
source

This should change the text.

 $('.showhidebtn').click(function() { $(this).val('hide it'); }); 
+1
source

Source: https://habr.com/ru/post/895838/


All Articles