I need show my newprice="" in input value, and in source.
$(".uzmi").on("click", function(e) {
$("inid").val($(this).attr('newprice'));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div data-value="VALUE 1" class="uzmi product-variation-colors__item helmet-variations" id=" " codeproduct=" " newprice="6043" variation_id="1407" change_img(0) "> Div 1</div>
<div data-value="VALUE 1 " class="uzmi product-variation-colors__item helmet-variations " id=" " codeproduct=" " newprice="2323 " variation_id="1407 " change_img(0)"> Div 2</div>
<div data-value="VALUE 1" class="uzmi product-variation-colors__item helmet-variations" id=" " codeproduct=" " newprice="9999" variation_id="1407" change_img(0) "> Div 3</div>
<input type=" " id="inid " name="variation_id " class="variation_id " value="6041 " />
This working for me, but I want my value to change in the source as well, not only visually.
2
Answers
You need to add "#" within you click function like this, because you are selecting by id:
And to the second part of your question, what do you mean by "source"?
inid.setAttribute("value", price)
added this line to update DOM tooSolution with Vanilla JavaScript