<div id="profile_ops" style="display:none">
<button class="ybutton" id="viewclick" >View</button>
<button class="ybutton" id="editclick" >Edit</button>
<button class="ybutton" id="change_pswd" >Change Password</button>
<button class="ybutton" id="change_pic" >Change Picture</button>
</div>
in this i show this div on particular condition and i hide the view button but on edit click i show the view button but i want to give click event of view button where should i give the click event of div ?
i have tried giving the click event in edit click but it is giving me errro?
To add a click event listener on div tag using JavaScript, we can call the addEventListener method on the selected div. to add a div with a class. Then we write: const div = document.
jQuery click() Method The click event occurs when an element is clicked. The click() method triggers the click event, or attaches a function to run when a click event occurs.
The HTMLElement. click() method simulates a mouse click on an element. When click() is used with supported elements (such as an <input> ), it fires the element's click event. This event then bubbles up to elements higher in the document tree (or event chain) and fires their click events.
If you want native JS to trigger click event without clicking then use the element id and click() method of JavaScript.
just assign the client event to each one
$(document).ready( function() {
$("#viewclick").click( function() {
// this will fire when you click view
});
$("#editclick").click( function() {
// this will fire when you click edit
// hide the view button here and upon submit, show it again
// like $("#viewclick").hide() or $("#viewclick").fadeOut()
});
});
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