⊗jqDmVAR 37 of 113 menu

Removing Only the Value of an Attribute in jQuery

Sometimes we need to leave an attribute, but remove its current value. Let's look at the following example. Let's say we have an input:

<input type="text" value="!!!" id="test">

In this case, we write the attribute, but add an empty value in quotation marks (without a space) as the second parameter.

$('#test').attr('value', '');

HTML the code will look like this - the attribute value will not disappear from the HTML code:

<input type="text" value id="test">

Modify the solution to the previous problem so that only the value www is removed, but not the attribute itself.

enru