求教一个获取class中的值写法

belatu 2011-09-30 08:26:59

<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript" src="http://bowser.effectgames.com/~jhuckaby/zeroclipboard/ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;

function init() {
// setup single ZeroClipboard object for all our elements
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );

// assign a common mouseover function for all elements using jQuery
$('.copy').mouseover( function() {
// set the clip text to our innerHTML
clip.setText( this.innerHTML );

// reposition the movie over our element
// or create it if this is the first time
if (clip.div) {
clip.receiveEvent('mouseout', null);
clip.reposition(this);
}
else clip.glue(this);

// gotta force these events due to the Flash movie
// moving all around. This insures the CSS effects
// are properly updated.
clip.receiveEvent('mouseover', null);
} );
clip.addEventListener( 'onComplete', my_complete );
function my_complete( client, text ) {alert("已复制!");}
}
</script>


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript" src="http://bowser.effectgames.com/~jhuckaby/zeroclipboard/ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;

function init() {
// setup single ZeroClipboard object for all our elements
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );

// assign a common mouseover function for all elements using jQuery
$('.copy').mouseover( function() {
// set the clip text to our innerHTML
clip.setText( this.innerHTML );

// reposition the movie over our element
// or create it if this is the first time
if (clip.div) {
clip.receiveEvent('mouseout', null);
clip.reposition(this);
}
else clip.glue(this);

// gotta force these events due to the Flash movie
// moving all around. This insures the CSS effects
// are properly updated.
clip.receiveEvent('mouseover', null);
} );
clip.addEventListener( 'onComplete', my_complete );
function my_complete( client, text ) {alert("已复制!");}
}
</script>
</head>
<body onLoad="init()">
<table>
<tr>
<td id="1" >
<span class="copy">copy text id1</span>
<span class="al">AAA</span>
</td>
<td id="2" >
<span class="copy">copy text id2</span>
<span class="al">BBB</span>
</td>

</tr>
<table>
<body>
</html>


请问如何在点击.copy后获得同id下.al中的值

并在
function my_complete( client, text ) {alert("已复制!(在这里显示.al的值)");}

请回代码 谢谢各位
...全文
96 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
星小野 2011-10-01
  • 打赏
  • 举报
回复
额..
s11ss 2011-09-30
  • 打赏
  • 举报
回复
clip.setText( $(this).siblings().first().text() );


{alert("已复制!" + client.clipText)}
belatu 2011-09-30
  • 打赏
  • 举报
回复
谢谢楼上的朋友
hookee 2011-09-30
  • 打赏
  • 举报
回复

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript" src="http://bowser.effectgames.com/~jhuckaby/zeroclipboard/ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;

function init() {
// setup single ZeroClipboard object for all our elements
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );

// assign a common mouseover function for all elements using jQuery
$('.copy').mouseover( function() {
// set the clip text to our innerHTML
clip.setText( this.innerHTML );

// reposition the movie over our element
// or create it if this is the first time
if (clip.div) {
clip.receiveEvent('mouseout', null);
clip.reposition(this);
}
else clip.glue(this);

// gotta force these events due to the Flash movie
// moving all around. This insures the CSS effects
// are properly updated.
clip.receiveEvent('mouseover', null);
} );
clip.addEventListener( 'onComplete', my_complete );
function my_complete( client, text ) {
alert("已复制!" + $(client.domElement).siblings(".al").html());
}
}
</script>
</head>
<body onLoad="init()">
<table>
<tr>
<td id="d1" >
<span class="copy">copy text id1</span>
<span class="al">AAA</span>
</td>
<td id="d2" >
<span class="copy">copy text id2</span>
<span class="al">BBB</span>
</td>
</tr>
</table>
</body>
</html>

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧