当链接是图像时,代码工作正常。但是当有闪光电影时我有问题。当需要将链接ID复制到imagesID输入框时,在地址栏中打开另一个未定义的页面。
<script type="text/javascript">
var $input = $("#imagesID"); // <-- your input field
$('a.thumb').click(function() {
var value = $input.val();
var id = $(this).attr('id');
if (value.match(id)) {
value = value.replace(id + ';', '');
}
else {
value += id + ';';
}
$input.val(value);
});
</script>
<ul class="thumbs">
<li>
<a class="thumb" id="62">
<img src="/FLPM/media/images/2A9L1V2X_sm.jpg" alt="Dock" id="62" class="floatLeft" />
</a>
<br />
<a href="?Process=&IMAGEID=62" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
<li>
<a class="thumb" id="61">
<img src="/FLPM/media/images/0E7Q9Z0C_sm.jpg" alt="Desert Landscape" id="61" class="floatLeft" />
</a>
<br />
<a href="?Process=&IMAGEID=61" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
<li>
<a class="thumb" id="60">
<img src="/FLPM/media/images/8R5D7M8O_sm.jpg" alt="Creek" id="60" class="floatLeft" />
</a>
<br />
<a href="?Process=&IMAGEID=60" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
<li>
<a class="thumb" id="59">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0" id="59" width="150" height="100" style="float:left; border:5px solid #CCCCCC; margin:5px 10px 10px 0;">
<param name="scale" value="exactfit">
<param name="AllowScriptAccess" value="always" />
<embed name="name" src="http://www.refinethetaste.com/FLPM/media/flashes/7P4A6K7M.swf"
quality="high" scale="exactfit" width="150" height="100"
type="application/x-shockwave-flash"
AllowScriptAccess="always"
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
P1_Prod_Version=ShockwaveFlash">
</embed>
</object>
</a>
<br />
<a href="?Process=&IMAGEID=59" class="thumb"><span class="floatLeft">DELETE</span></a>
</li>
</ul>
答案 0 :(得分:0)
并非所有a.thumb元素都具有id属性,最明显的是与flash对象关联的属性。
答案 1 :(得分:0)
答案 2 :(得分:0)
您是否尝试过阻止默认的浏览器操作?
$('a.thumb').click(function(event) {
event.preventDefault();
// ... snip ...
}