English 中文(简体)
频率-超()功能——如何包括甄选者 Html [复制]
原标题:Jquery HTML() function - how to include selector Html [duplicate]
  • 时间:2011-10-27 15:03:18
  •  标签:
  • jquery
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
Get selected element s outer HTML

我怀疑这是一个真正的问题,但当你称“Html()”在“J Query”运作时,它会把选定的诺子归还给Html。 在返回的Html中是否有任何列入选定说明的途径? 例如,关于下列超文本

<div class="demo-container">
  <div class="demo-box">Demonstration Box</div>
</div>

this call $( div.demo-container ).html(); returns

<div class="demo-box">Demonstration Box</div>

我如何回来

<div class="demo-container">
  <div class="demo-box">Demonstration Box</div>
</div>

得到帮助!

最佳回答

您可以把其复制件填入bor地,并用超文本处理:

var str = $( div.demo-container ).clone().wrap( <div/> ).parent().html();
问题回答

撰写这一延伸,例如here

jQuery.fn.outerHTML = function(s) {
   return (s)
   ? this.before(s).remove()
   : jQuery("&lt;p&gt;").append(this.eq(0).clone()).html();
}

那么,当你们想使用:

$( #myTag ).outerHTML();

可为您工作:

$( div.demo-container ).parent().html();
$( div.demo-container ).parent().html() //Only w或ks in this specific situation

$( div.demo-container )[0].outerHTML; //Only w或ks in IE and Chrome




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签