我有一些例子
target = $this.attr('data-target') || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')
,但我不明白它是如何工作(
如果我使用的console.log()
console.log(target, e.preventDefault(), (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
我得到
#collapseTwo undefined #collapseTwo
是的,我明白,e.preventDefault()返回結果 - 「垃圾」......但爲什麼e.preventDefault()與||一起使用運營商?
它的作品如何?
ok,e.preventDefault()永遠不會返回結果true,爲什麼它在這個表達式中使用?錯誤的樣式代碼? – Vitaliy 2012-03-29 20:42:03
是的,其實這就是爲什麼href然後檢查,如果數據目標有一個值,這意味着它不會有href,所以沒有必要取消。哎呀。 – 2012-03-29 21:59:08