ssahu
ssahu

Reputation: 888

Manipulation of Table using Jquery

I need to create a table with 5 rows and 5 columns with numbers from 1 to 25 filling up the cells. On Mouse over the table row multiply the number inside the cell with 2 and on mouse out divide the number by 2 using 'each' functionality.

Can anyone please help?

Upvotes: 0

Views: 101

Answers (1)

Vikash
Vikash

Reputation: 989

Create your HTML table and write the values. Use Jquery for the behaviour. You can do something like this in jQuery:

$("tr").hover(
  function () {
    $(this).find("td").each(function(){
        var text = parseInt($(this).text());
        $(this).text(text*2);
    });
  },
  function () {
    $(this).find("td").each(function(){
        var text = parseInt($(this).text());
        $(this).text(text/2);
    });
  }
);

Upvotes: 2

Related Questions