小编use*_*711的帖子

如何使用 jQuery .get() 获取原始 html 字符串

我需要获取带有<div>标签和所有内容的原始 html,并将其放入变量字符串中。

所以如果我有一个单独的文件 test.html

<div>
<div><img src="images/htc_hero_wallpaper_01.jpg" width="20%" height="20%" alt="" /></div>
WORKS!!!
</div>
Run Code Online (Sandbox Code Playgroud)

我需要 jQuery 命令

$.ajax({
  url: "test.html",
  success: function(){

 var htmlraw = ?????
 alert(htmlraw)  /// should print the raw test.html
  }
});
Run Code Online (Sandbox Code Playgroud)

打印

<div>
<div><img src="images/htc_hero_wallpaper_01.jpg" width="20%" height="20%" alt="" /></div>
WORKS!!!
</div>
Run Code Online (Sandbox Code Playgroud)

html ajax jquery get

3
推荐指数
1
解决办法
7235
查看次数

在父div中显示隐藏div

父div中有几个子div.我想展示/隐藏一个特定的孩子.

<div id="parent">
    <div id="child0">Text here</div>
    <div id="child1">Text here</div>
</div>
Run Code Online (Sandbox Code Playgroud)

我希望鼠标在div id ="parent"上显示hide div id = child0,父div中的其他所有内容保持不变(可见).

html javascript show-hide

-1
推荐指数
1
解决办法
1761
查看次数

标签 统计

html ×2

ajax ×1

get ×1

javascript ×1

jquery ×1

show-hide ×1