Answer the question
In order to leave comments, you need to log in
How to correctly change the value data-* attribute?
Hello,
Sorry for the chaotic presentation, honestly .. in a hurry))))
I make a key that, when .onclick sends a certain information to the parent page via js. The page opens in an iframe and then I pass text info to the parent page via js when clicked.
But that's not the point.
There is this code tied to onclick :
document.getElementById('dt-sc-buttonl').setAttribute('data-price','<?php the_field('price'); ?>');
There are two keys, when you click on one - it sets the attribute = price , when you click on another price2
Actually, when you press the key, I see changes in the data-price field through the debugger. But when sending to the parent page - the price is always equal to value at the first keystroke.
That is, by clicking on one key: 1) sets the attribute
2) I see visual changes in the debugger
3) Sends the price from the first key - everything is good
4) Click on another key - I see visual changes in the debugger
5) *** Sends the price from the first keys - not buzzing (should be from the second one) As a matter of
fact, if you first press the second key, it will always send the attribute from the second one even with a visual change when clicking on the first one. Trouble...
Code
Answer the question
In order to leave comments, you need to log in
PHP does not wait for any other events or conditions other than PHP itself
. Gavnocode example:
<input type="button" onclick="<? header('Location: http://...'); ?>">
$('somenthing').data(123)
jqapi.com/#p=data
By the way, you didn't attach the code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question