javascript - Change label's name using image button is not working -


this code supposed change name of label when click image button.

this not happening. 1 thing observed when closely is: when button clicked, label changes changes original value immediately.

when use normal button change working.

<html>     <body>         <script type="text/javascript">             function change(n)             {                 var e=document.getelementbyid("name");                 e.innerhtml='jnbjkvnkx';             }         </script>         <form>             <label for="name" style="width: 300px; padding-left: 5cm" id="name">hemanth</label>             <input type="image" src="page31.png" onclick="change('name')">         </form>     </body> </html> 

the label value doesn't changed because once click on button, page refreshes new page x , y coordinates image type.

there several ways fix issue:

1.) use input type = button , using css change background image of button.

2.) use <a href='#' onclick='change()'><img src='page31.png'></a>


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -