Reputation: 447
I'm using a Javascript to change the text on a form submit button, this is the code I'm using:
<script type="text/javascript">
$(document).ready(function(){
document.getElementById("button").value="New Button Text";
});
</script>
The code work perfectly, but I need to change it so that it effects the id #button
within a div with the id of #formwrap
. So basically I need to .getElementById("button")
contained within the div with a id of #formwrap
Upvotes: 0
Views: 1808
Reputation: 18861
If you are already using jquery, why not just do
$('#formwrap #button').val('New Button Text');
?
It's simply CSS-like selector, similar to what you'd use in querySelectorAll()
.
It will match for example this button:
<div id="formwrap"><input type="button" id="button"></div>
But keep in mind that only one element can have the same ID.
Maybe you wanted class? Then you'd use .button
instead of #button
.
Upvotes: 2