html
Set default attribute values to all tags at once.

Set default attribute values to all tags at once.

app.js

$(document).ready(function() {
	// Variables declarations

    $('input').attr('autocomplete', 'off');
}

Now everywhere, the input tag will contain autocomplete as off. This is on by default. So, if you want to make it off by default, you can use this approach.

<input autocomplete="on">

Are you trying to do these on some input tag? Is it not working? Well, I got covered for you 🙂. Here is what you need to do. Under your style.css file, add following code.

style.css

.smAutoCompleteOn {}

Now replace above code in app.js file with following code.

$(document).ready(function() {
	// Variables declarations

    $('input:not(.smAutoCompleteOn)').attr('autocomplete', 'off');
}

Note, I have added :not(.smAutoCompleteOn) after input tag. Now, this will set autocomplete to off only if the input tag has not set .smAutoCompleteOn as class. Here is an example on how you can call this class.

<input class="smAutoCompleteOn">

Now, on this input tag, autocomplete is on.

Well, that’s all for today. I hope it was helpful.

Thanks

Leave a Reply