久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='1emDU'></bdo><ul id='1emDU'></ul>
<i id='1emDU'><tr id='1emDU'><dt id='1emDU'><q id='1emDU'><span id='1emDU'><b id='1emDU'><form id='1emDU'><ins id='1emDU'></ins><ul id='1emDU'></ul><sub id='1emDU'></sub></form><legend id='1emDU'></legend><bdo id='1emDU'><pre id='1emDU'><center id='1emDU'></center></pre></bdo></b><th id='1emDU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1emDU'><tfoot id='1emDU'></tfoot><dl id='1emDU'><fieldset id='1emDU'></fieldset></dl></div>

    <legend id='1emDU'><style id='1emDU'><dir id='1emDU'><q id='1emDU'></q></dir></style></legend>

  1. <small id='1emDU'></small><noframes id='1emDU'>

    1. <tfoot id='1emDU'></tfoot>

      使用 javascript/jQuery 從 HTML 字符串中獲取屬性值

      Using javascript/jQuery to get attribute values from an HTML string(使用 javascript/jQuery 從 HTML 字符串中獲取屬性值)
        • <i id='j9AK6'><tr id='j9AK6'><dt id='j9AK6'><q id='j9AK6'><span id='j9AK6'><b id='j9AK6'><form id='j9AK6'><ins id='j9AK6'></ins><ul id='j9AK6'></ul><sub id='j9AK6'></sub></form><legend id='j9AK6'></legend><bdo id='j9AK6'><pre id='j9AK6'><center id='j9AK6'></center></pre></bdo></b><th id='j9AK6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='j9AK6'><tfoot id='j9AK6'></tfoot><dl id='j9AK6'><fieldset id='j9AK6'></fieldset></dl></div>

              <bdo id='j9AK6'></bdo><ul id='j9AK6'></ul>
              <legend id='j9AK6'><style id='j9AK6'><dir id='j9AK6'><q id='j9AK6'></q></dir></style></legend>
              <tfoot id='j9AK6'></tfoot>
                <tbody id='j9AK6'></tbody>

              <small id='j9AK6'></small><noframes id='j9AK6'>

              • 本文介紹了使用 javascript/jQuery 從 HTML 字符串中獲取屬性值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個包含文本和圖像的 HTML 字符串,例如

                I have an HTML string that contains text and images, e.g.

                <p>...</p>
                <img src="..." />
                <p>...</p>
                

                我需要獲取第一張圖片的 src 屬性.圖片可能出現在 <p> 之后,也可能不出現,并且可能有多個圖片,或者根本沒有圖片.

                I need to get the src attribute of the first image. The image may or may not come after a <p> and there could be more than one image, or no image at all.

                最初,我嘗試將字符串附加到 DOM 并進行過濾.但是,如果我這樣做,瀏覽器會請求所有外部資源.在我的情況下,這會增加很多不必要的開銷.

                Initially, I tried appending the string to the DOM and filtering. But, if I do this the browser requests all of the external resources. In my situation, this adds a lot of unnecessary overhead.

                我最初的做法:

                var holder = $('<div></div>'); 
                
                holder.html(content);
                
                var src = holder.find('img:first').attr('src'); 
                

                如何在不附加 HTML 的情況下獲取第一張圖片的 src?我需要使用正則表達式,還是有更好的方法?

                How can I get the src of the first image without appending the HTML? Do I need to use a regular expression, or is there a better way?

                解決方案需要基于 javascript/jQuery——我沒有使用任何服務器端語言.

                The solution needs to be javascript/jQuery based – I'm not using any server side languages.

                我的問題非常類似于:http://forum.jquery.com/topic/parsing-html-without-retrieving-external-resources

                謝謝

                推薦答案

                這個

                $("<p><blargh src='whatever.jpg' /></p>").find("blargh:first").attr("src")
                

                返回 whatever.jpg 所以我想你可以試試

                returns whatever.jpg so I think you could try

                $(content.replace(/<img/gi, "<blargh")).find("blargh:first").attr("src")
                

                編輯

                / 而不是 "<img"

                這篇關于使用 javascript/jQuery 從 HTML 字符串中獲取屬性值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                  <tbody id='0mERX'></tbody>

                    <tfoot id='0mERX'></tfoot>

                    1. <small id='0mERX'></small><noframes id='0mERX'>

                      <i id='0mERX'><tr id='0mERX'><dt id='0mERX'><q id='0mERX'><span id='0mERX'><b id='0mERX'><form id='0mERX'><ins id='0mERX'></ins><ul id='0mERX'></ul><sub id='0mERX'></sub></form><legend id='0mERX'></legend><bdo id='0mERX'><pre id='0mERX'><center id='0mERX'></center></pre></bdo></b><th id='0mERX'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0mERX'><tfoot id='0mERX'></tfoot><dl id='0mERX'><fieldset id='0mERX'></fieldset></dl></div>

                          <bdo id='0mERX'></bdo><ul id='0mERX'></ul>
                          <legend id='0mERX'><style id='0mERX'><dir id='0mERX'><q id='0mERX'></q></dir></style></legend>
                          主站蜘蛛池模板: 亚洲国产一区二区三区在线观看 | 欧美日韩一区二区在线播放 | 国产高清视频 | 国产精品爱久久久久久久 | 男女深夜网站 | 国产精品一区在线观看 | 亚洲高清av| 日韩国产欧美一区 | 国产视频综合 | 久久久久久久久久久91 | 一级国产精品一级国产精品片 | 国产视频中文字幕 | 亚洲成人三级 | 中文字幕亚洲专区 | 国产三级| 欧洲精品在线观看 | 日韩字幕| 中文字幕高清免费日韩视频在线 | 国产日韩久久 | 国产精品久久久久久久久久免费看 | 宅男伊人| 国产精品欧美一区二区三区 | 亚洲资源站 | 91精品国产乱码久久蜜臀 | 成人在线小视频 | 91久久久www播放日本观看 | 一区二区亚洲 | 国产一级片精品 | 放个毛片看看 | 理伦毛片| 久久久高清 | 色综合欧美 | 国产一级在线 | 黄色av观看 | 午夜视频在线观看视频 | 精品1区2区| 老司机67194精品线观看 | 国产精品久久精品 | 欧美日韩黄色一级片 | 91亚洲国产 | 亚洲色综合|