开发者

how do jquery script

I'm here with the following code in prototype

var id = "bugtv";

if(navigator.userAgent.indexOf("MSIE")>-1){
   flashObj = $(id+'Obj');
}else{
   flashObj = $(id+'Emb');
}

I would like to jQuery

how I do it

flashObj = $(id+'Obj');
flashObj = $(id+'Emb');

in jquery?

thanks

edit

function MontaBugtvFlash(url) {

var id = "bugtv";
var width = "100%";
var height = "100%";
var wmode = "transparent";

var swfbugtv=[];

swfbugtv.push('<object id="'+id+'Obj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="'+height+'" width="'+width+'">');
swfbugtv.push('<param name="movie" value="'+url+'">');
swfbugtv.push('<param name="quality" value="high">');
swfbugtv.push('<param name="wmode" value="'+wmode+'">');
swfbugtv.push('<param na开发者_如何学编程me="menu" value="false">');
swfbugtv.push('<embed src="'+url+'" id="'+id+'Emb" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="'+wmode+'" menu="false" height="'+height+'" width="'+width+'">');
swfbugtv.push('</object>');

document.write(swfbugtv.join(""));

if(navigator.userAgent.indexOf("MSIE")>-1){
   flashObj = $(id+'Obj');
}else{
   flashObj = $(id+'Emb');
}

};


<div id="flashHolder">
  <script type="text/javascript" language="javascript">MontaBugtvFlash("blubix.swf");</script>
</div>


I think this should do it:

var id = "bugtv";
if ($.browser.msie) {
 flashObj = $("#" + id + "Obj");
} else {
 flashObj = $("#" + id + "Emb");
}

or a shorter version:

var id = "bugtv";
flashObj = $("#" + id + $.browser.msie?"Obj":"Emb"));


jQuery.browser

var id = "bugtv";

if($.browser.msie){
   flashObj = $('#' + id+'Obj');
}else{
   flashObj = $('#' + id+'Emb');
}


You'll want to go over the jQuery selectors API docs. In order to find an element by ID you need to use a css-like selector, so:

$('#' + id + 'Obj')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜