开发者

if event is click and drag jquery

i have a table how to change the tr's background color during click and drag?

<table id="tables">
 <tbody>
  <tr>
   <td>1.</td>
   <td>John Smith</td>
   <td>Male</td>
   <td>Active</td>
  <tr>
  <tr>
   <td>2.</td>
   <td>Pepe Smith</td>
   <td>Female</td>
   <td>Active</td>
  <tr>
 </tbody>
</table>

when i click and drag anywhere in the row.. the background color should cha开发者_如何学运维nge.. is this possible using jquery only?


You haven't said how you're dragging them. If you're using jQuery UI's Draggable (can it drag rows?), you can either use CSS or events.

CSS:

From the docs:

Draggable elements gets a class of
ui-draggable
During drag the element also gets a class of
ui-draggable-dragging

And so:

#tables tr.ui-draggable-dragging {
    background-color: yellow;
}

Events:

The docs also talk about the start and stop events, which you could use if you didn't want to use CSS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜