亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

angular.js - 指令裡產(chǎn)生的html怎麼解析
世界只因有你
世界只因有你 2017-05-15 17:12:05
0
2
911
return {
            restrict: 'EA',
            link: function (scope, element, attr) {
                element.bind('mouseenter', function() {
                    this.after("<p style='position: absolute;'><img src=" + this.src + " /></p>")
                });
            }
        }

例如像上邊這樣,使用jquery的after方法,這個(gè)p在頁面顯示成了字串,怎麼才能直接解析出來?

世界只因有你
世界只因有你

全部回覆(2)
Peter_Zhu

利用 $compile

寫了個(gè)線上小demo

http://embed.plnkr.co/egEOkZv...

淡淡煙草味

題主的引號(hào)問題所導(dǎo)致的

this.after("<p style='position: absolute;'><img src=" + this.src + " /></p>")

很明顯這裡的url少了個(gè)引號(hào)呢、img的src要用引號(hào)包裹、可以加單引號(hào)在兩邊

this.after("<p style='position: absolute;'><img src='" + this.src + "' /></p>")

你在頁面上的字串也是src沒引號(hào)

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板