Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Get the ID using javascript/jquery Re: Get the ID using javascript/jquery

#59373

Getting the ID of the div in a click event is simply a case of this.id, sending it to a PHP using AJAX is a matter of using $.post.

This example makes all divs clickable, you will obviously want to use a better selector. Also, it will send the id of the div to test.php and update the div with an id of news – you should change these to suit your needs.

In the PHP file the id can be referenced using $_POST – you should addslashes() before using it a SQL query.

Code: