<html>
<script src="http://code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script>
<script>
$(function(){
$("table tr td").click(function()
{ /*获取table 中 点击的td 值*/
var $this = $(this); //get clicked td value
alert($this.text());
//$this就是这个行,你点哪行,哪行就有反应。
});
$("table tr ").click(function(){
var $this =$(this);
var i=0;
$this.find("td").each(function(){ //only traverse clicked tr
//$("table tr ").find("td").each(function(){ //will traverse all tr
var $thisa =$(this);
alert($this.text()); //show all td in one alert
alert($thisa.text()); //show all td one bye one alert
//alert($this.find("td").eq(i).text());
i++;
});
alert($this.find("td").eq(2).text()); //get td eq=3 value
});
})
</script>
<table>
<tr><td>行1列1</td><td>行1列2</td><td>行1列3</td></tr>
<tr><td>行2列1</td><td>行2列2</td><td>行2列3</td></tr>
</table>
</html>
/**
* Created by 2015-218-pc on 6/9/15.
*/
<pre style="font-family: Menlo; font-size: 12pt; background-color: rgb(255, 255, 255);"><span style="background-color:#efefef;"><</span><span style="color:#000080;background-color:#efefef;"><strong>button </strong></span><span style="color:#0000ff;background-color:#efefef;"><strong>valid=</strong></span><span style="color:#008000;background-color:#efefef;"><strong>"</strong></span><span style="background-color:#f7faff;">{{</span><span style="color:#000080;background-color:#f7faff;"><strong>$</strong></span><span style="background-color:#f7faff;">listItem.id}}</span><span style="color:#008000;background-color:#efefef;"><strong>" </strong></span><span style="color:#0000ff;background-color:#efefef;"><strong>userid=</strong></span><span style="color:#008000;background-color:#efefef;"><strong>"</strong></span><span style="background-color:#f7faff;">{{</span><span style="color:#000080;background-color:#f7faff;"><strong>$</strong></span><span style="background-color:#f7faff;">listItem.user_id}}</span><span style="color:#008000;background-color:#efefef;"><strong>" </strong></span><span style="color:#0000ff;background-color:#efefef;"><strong>class=</strong></span><span style="color:#008000;background-color:#efefef;"><strong>"btn btn-xs btn-default auditPass" </strong></span><span style="color:#0000ff;background-color:#efefef;"><strong>role=</strong></span><span style="color:#008000;background-color:#efefef;"><strong>"button"</strong></span><span style="background-color:#efefef;">></span>通过<span style="background-color:#efefef;"></</span><span style="color:#000080;background-color:#efefef;"><strong>button</strong></span><span style="background-color:#efefef;">></span>
$(function(){ //审核拒绝 $("#example1 tr td").find(".btn-reject").click(function(e){ var clickedTr = $(this).parent().parent(); var clickTd = $(this).parent(); var userid = e.currentTarget.attributes['valid']
.nodeValue; //获取点击的event中自定义的属性值 valid
bootbox.dialog({ title: "拒绝理由.", message: '<div class="row"> ' + '<div class="col-md-12"> ' + '<div class="form-group"> ' + '<label class="col-md-4 control-label" for="name">拒绝理由</label> ' + '<div class="col-md-4"> ' + '<input id="rejectReason" name="rejectReason" type="text" placeholder="理由" class="form-control input-md"> ' + '</div> ' + '</div> ' + '</div> </div>', buttons: { success: { label: "确定", className: "btn-success", callback: function () { var reason = $('#rejectReason').val(); var data = reason + "/---/" + userid + "/---/reject"; clickTd.html(''); //ajaxCustom("/merchant/audit",'post',data,"alert(re)"); } } } } ); }); //审核通过 $(".btn-pass").click(function(e){ var userid = e.currentTarget.attributes[0].nodeValue; var reason = null; var data = reason + "/---/" + userid + "/---/pass"; var restatus = '$this.html()'; ajaxCustom("/merchant/audit",'post',data,"alert(re)"); });});function ajaxCustom(url,type,data,sdata){ $.ajax({ url: url, type: type, data: 'data='+ data, success: function(re){ eval(sdata); }, error:function(){ } })}