How could I use jquery to find out this button within a div with class name "blueheaderbar accordionButton on" then change button value 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>
In this article, we will find how to get all elements of a specific class inside an HTML div tag. To do this we will use HTML DOM querySelectorAll () method. This method of HTML DOM (document object model) returns all elements in the document that matches a specified CSS selector (s). The syntax to use this method is as follows.
The :button selector selects button elements, and input elements with type=button. Tip: Using input:button as a selector will not select the button element.
For instanse you can do The last one will match every myclass inside myDiv, including myclass inside myclass. If you want to select every element that has class attribute "myclass" use If you want to select only div elements that has class attribute "myclass" use try this instead $ (".video-divs.focused").
The <input type="button"> defines a clickable button (mostly used with a JavaScript to activate a script). The numbers in the table specify the first browser version that fully supports the element.
I think the answer is:
$("div.blueheaderbar.selected").find("input").val("hide it");
"blueheaderbar accordionButton selected"
isn't "a" single class name, but three. The CSS selector to select an element with all three classes is
.blueheaderbar.accordionButton.selected
(notice the lack of spaces!).
So to find an input inside there with jQuery is:
var $input = jQuery(".blueheaderbar.accordionButton.selected input");
or
var $input = jQuery(".blueheaderbar.accordionButton.selected").find("input");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With