当前位置: 代码迷 >> JavaScript >> 哪位高手能帮小弟我解释一下下面这段代码
  详细解决方案

哪位高手能帮小弟我解释一下下面这段代码

热度:71   发布时间:2012-04-11 17:42:33.0
谁能帮我解释一下下面这段代码
(editor.options.relativePath ? img.getAttribute( "src", 2 ).replace( "&", "&" ) : img.src.replace( "&", "&" ))

------解决方案--------------------
是editor.options.relativePath就得到src属性并用&替换&(img.getAttribute( "src", 2 ).replace( "&", "&" )) 不是就直接用替换&(
------解决方案--------------------

等价于 
if (editor.options.relativePath ){
img.getAttribute( "src", 2 ).replace( "&", "&" ) :
}else{
img.src.replace( "&", "&" )
}
------解决方案--------------------
探讨
等价于
if (editor.options.relativePath ){
img.getAttribute( "src", 2 ).replace( "&", "&" ) :
}else{
img.src.replace( "&", "&" )
}