Here is the example :
$("input[name=search_product_id]").on("click", function() {
var _parent = this;
$("input[name=search_product_id]").filter(function() {
if($(_parent) != $(this)) {$(this).val("")};
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<input type="text" name="search_product_id" id='0'>
<br>
<input type="text" name="search_product_id" id='1'>
When I click on an input it should clear all other inputs EXCEPT the one I clicked upon. So if I click on the first input and start typing, the second input should be cleared, if I want to click on the first input again to hover the mouse on a past text, the full text should stay, which in my code it does not and the text in all inputs is cleared on every click. Any idea why is my code not working and possible solutions ?
So what's happening : If I write txt on the first input, and then click again on the first input after the first t to add an e to have text rather than txt, that click should not clear the first input. It should only clear the text of any other inputs with the same name tag.
I hope my question is clear. Feel free to ask for addition explanation !