<div id="product" class="input-select">
<div id="product_select_value" style="font-weight:bold">TEXT 1</div>
<input type="hidden" name="product" data-only_capital="" value="73">
<div id="product_droplist" class="droplist" style="display: none;">
<div data-only_capital="" cat="2" rel="73">TEXT 1</div>
<div data-only_capital="" cat="2" rel="84">TEXT 2</div>
</div>
</div>
<script>
$( document ).ready(function() {
function hidePayment1()
{
var x = document.getElementById("product_select_value").innerHTML;
if(x == '1'){
alert('Hide some data');
}
else{
alert('Show some data');
}
}
hidePayment1();
document.getElementById ("product_select_value").addEventListener ("click", hidePayment1, false);
});
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="product_select_value" style="font-weight:bold">2</div>
<input type="text" id="input">
<script src="index.js"></script>
</body>
</html>
// Input for changing target DIV
const input = document.getElementById('input')
input.addEventListener('change', function(e) {
targetNode.innerHTML = e.target.value
})
// Select the node that will be observed for mutations
const targetNode = document.getElementById('product_select_value')
// Callback function to execute when mutations are observed
function callback(mutationsList) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
if(mutation.target.textContent === '1') {
console.log('Hide some data')
} else {
console.log('Show some data')
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback)
// Start observing the target node for configured mutations
observer.observe(targetNode, { childList: true })
// Later, you can stop observing
// observer.disconnect()