How To Remove Attributes From Html Using Javascript?
I have an HTML with say a textfield (input element). This simply displays a text field on my page with a default v
Solution 1:
...I don't want to see this default value.
Just set the value
property directly to an empty string.
document.getElementsByName('capacity')[0].value = '';
Solution 2:
Give your text field and id like <input name="capacity" type="text" id="text" value="blah blah blah">
document.getElementById['text'].value = "";
Solution 3:
This is your html tag. You will need to add a ID to it
<inputid="capacity" name="capacity"type="text" value="blah blah blah">
This is just to fire the javascript function
<inputtype="submit" value="Click" onclick="javascript:return reset();" />
The following function will reset the value of the selected element
<scripttype="text/javascript"language="javascript">functionreset() {
document.getElementById("capacity").value = "";
returnfalse; // In order to avoid postback
}
</script>
If you are not using form and you want to use it with just the name you can try the following
this.capacity.value = '';
Post a Comment for "How To Remove Attributes From Html Using Javascript?"