tags:

views:

96

answers:

4

Hi all;

Jquery Code:

$("[id$=gridvv] tr").filter(function() { 
   return $('td', this).length && !$('table', this).length 
}).click(function() {
   Alert('test');
});

This code should select all <tr> but I need .locked click return all <tr> pls help

http://jsbin.com/uheni3/edit
+1  A: 

This ??

$('td.locked').click(function(){
  // your code here
});

Updated Based On Comment

Give your table an id:

<table id="mytable">
  <tr>
    <td class="locked">Blabla<td>
    <td>test1</td>
    <td>test2</td>
  </tr>
</table>

JQuery:

$('td.locked').click(function(){
  $('#mytable tr').each(function(){
    // manipulate each tr now....
  });
});
Sarfraz
@Sarfraz this code return all <tr> but i need '.locked' click return all <tr> pls help
Oraclee
A: 
$('td[class="clicked"]').click(function() {
// your code
});
Bytecode Ninja
No your code...
Oraclee
+1  A: 

I either don't understand what you are trying to do, or it looks like complete overkill.

$('table').find('.locked').bind('click', function(){
   alert('test');
}

should bind a click handler to that td. if you want to only have "one" click, use

.one()

instead of .bind()

or, use

$(this).unbind();

within the event handler.

Kind Regards

--Andy

jAndy
@jAndy ı need '.locked' column click select all row ? pls help
Oraclee
this code return all <tr> but i need '.locked' click return all <tr> pls help
Oraclee
@oraclee, writing the same comment on every single persons post doesn't help. What you have written others have solved, if it isn't want you want you need to write something different to explain why it doesn't work.
Blair McMillan
@Blair McMillan @jAndy http://jsbin.com/uheni3/edit
Oraclee
A: 
$("[@id$=gridvv] tr").filter(function() { return $('td', this).length && !$('table', this).length })

This code return all < tr > inside elements those have "id" ends by "gridvv", and < tr > should contain < td > and not contain < table >. So may be you want to add one more yet rule like:

$("[@id$=gridvv] tr.locked")...

Edit: To select all < tr > :

$("td.locked").click(function(){var allTr = $(this).parent().parent().children(););

Apply any styles to allTr like this: allTr.css("color", "#ffffcc");

chapluck
@chapluck yes this code return all <tr> but i need '.locked' click return all <tr> pls help
Oraclee
@chapluck no your code no all <tr> this click <tr> return
Oraclee
it returns all tr inside a table that contains source td
chapluck
@chapluck http://jsbin.com/uheni3/edit
Oraclee
http://jsbin.com/uheni3/4/edit, Greatful servise. Thnks. I tried my code - all works great.$(document).ready(function() {$("td.locked").click(function(){var allTr = $(this).parent().parent().children().css("color", "#1fafcc");});})
chapluck