读书人

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

发布时间: 2012-04-11 17:42:33 作者: rapoo

谁能帮我解释一下下面这段代码
(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( "&", "&" )
}

读书人网 >JavaScript

热点推荐