JQuery – $( this ).attr('value') returns undefined

Advertisements I’m trying to use JQuery to get the value or id of a li element on clicking. Everything I’ve tried returns undefined HTML <ul id="list" class="content-ul"> <li value="0"><img src="/image0.png" /></li> <li value="1"><img src="/image1.png" /></li> <li value="2"><img src="/image2.png" /></li> <li value="3"><img src="/image3.png" /></li> </ul> Javascript $( ‘#list li’ ).click( ( event ) => { var… Read More JQuery – $( this ).attr('value') returns undefined

Use data from variable in another function

Advertisements I’ve got a function like this (value is from select): function getSelectValuePower () { var power = document.getElementById("power").value; sessionStorage.setItem("power", power); console.log(power); } How can I use value from variable power in another function ? For example : I want to use it here : function getValue () { var number = 10; var selectedValue… Read More Use data from variable in another function

How to change date timestamp from unix to localDateString in event listener

Advertisements I have a homework of Javascript exercise that goes like this: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Producst</title> <link rel="stylesheet" href="styles.css" /> </head> <body dir="rtl"> <main id="root"></main> <button class="btn" id="changeProducts">Make Changes</button> <script src="script.js"></script> </body> </html> Here we have 5 products that are getting written at <main id="root"></main>… Read More How to change date timestamp from unix to localDateString in event listener

display the total input rounded up

Advertisements thank you in advance for your help. I was wondering how can I do to display the total rounded up in case of odd number. Thanks Here is the code: $(document).ready(function() { $(‘.variable-field’).on(“input”, function() { var $row = $(this).closest(‘tr’); var qty = $row.find(‘.quantity’).val() || 0; $row.find(‘.totalcostprice’).val(qty / 3); }); }); <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script&gt; <table class=”table… Read More display the total input rounded up

On change method JQuery bug – JQuery

Advertisements I’m trying to figure out when a user selects an element of the select and what element it is through jquery like so: $(‘#firstSelect’).on(‘change’, function() { console.log("selected"); alert( $(this).find(":selected").val() ); }); I’ve also included the library at the top of the document: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script&gt; But the method doesn’t work, when I select there is… Read More On change method JQuery bug – JQuery