Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Prototypejs 如何在原型上按类名获取div的html_Prototypejs - Fatal编程技术网

Prototypejs 如何在原型上按类名获取div的html

Prototypejs 如何在原型上按类名获取div的html,prototypejs,Prototypejs,我在JQuery工作之前,我有点不明白如何在原型上获得的asd <div class="quote_content"> <a>asd</a> </div> 自闭症 谢谢 更新 我有一个函数可以做到这一点: <script type="text/javascript">// <![CDATA[ function showCompare() { var quote_content = $$(".quote_co

我在JQuery工作之前,我有点不明白如何在原型上获得
asd

<div class="quote_content">
     <a>asd</a>
</div>

自闭症
谢谢

更新

我有一个函数可以做到这一点:

<script type="text/javascript">// <![CDATA[
function showCompare() {
    var quote_content = $$(".quote_content");
    win = new Window({className: "mac_os_x", title: "Sample", width:800, height:400, destroyOnClose: true, recenterAuto:false});

    win.getContent().innerHTML = quote_content;
    win.showCenter();
}
// ]]></script>
//

但是
quote\u content
输出是
[object htmldevelment]

首先需要知道的是,is class属性是在类名后用一个点来标识它, 在您的情况下,
.quote\u content
那么您必须使用子元素,我知道两种方法

一,-

二,-

或者,如果子元素具有类:

一,-

二,-


如果您只想在页面中查找任何包含classname quote_内容的元素并返回其HTML内容,请尝试以下操作:

$$('.quote_content').each(function(elm){
  // do whatever you like with elm.innerHTML
  alert( elm.innerHTML );
  // note that any whitespace, as in your example
  // will be preserved. You may prefer this instead:
  var child = elm.down();
  alert( child.outerHTML );
  // this only works if you know there is only one
  // child element, though
});
$('.quote_content').children("a")
$('.quote_content > .child_element_class')
$('.quote_content').children(".child_element_class")
function showCompare() { 
  var quote_content = document.getElementById('quote_content'); 
  console.log(quote_content); 
  win = new Window({className: "mac_os_x", title: "Sample", width:800, height:400, destroyOnClose: true,   recenterAuto:false});

  win.getContent().innerHTML = quote_content.innerHTML; 
  win.showCenter(); 
}
$$('.quote_content').each(function(elm){
  // do whatever you like with elm.innerHTML
  alert( elm.innerHTML );
  // note that any whitespace, as in your example
  // will be preserved. You may prefer this instead:
  var child = elm.down();
  alert( child.outerHTML );
  // this only works if you know there is only one
  // child element, though
});