English 中文(简体)
j的 style体含量?
原标题:Get style tag content with jQuery?
  • 时间:2011-11-18 21:15:18
  •  标签:
  • jquery

www.un.org/Depts/DGACM/index_spanish.htm 问题

I m试图获取内容,带上标签,但我不能让它工作。

www.un.org/Depts/DGACM/index_spanish.htm 准则是什么?

我使用j Query,并试图用文字()和(html)获得风格的内容。 它不可行。

www.un.org/Depts/DGACM/index_spanish.htm 我的代码

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet/less" type="text/css" href="css/style.less">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>

    <style id="less:concepts-less-css-style" media="screen" type="text/css">
        body {
            padding: 10px;
            background: blue;
        }
    </style>

</head>
<body>
<script src="js/less-1.1.5.min.js" type="text/javascript"></script>
<script type="text/javascript">
        jQuery(document).ready(function($) {        
            var my_id = $( style ).attr( id );
            var test = $( #less:concepts-less-css-style ).text();
            var test2 = $( #less:concepts-less-css-style ).html();
            alert(test + "#" + test2 + "#" + my_id);
        });
    </script>
</body>
</html>
最佳回答

我认为,你必须逃脱你身份证上的殖民地,因为它通常意味着选择子公司。 见。 为讨论这一问题,在CSS 挑选人中处理一个元件。

$( #less\:concepts-less-css-style )

我个人避免了在我的国际发展法或阶级价值中具有特别意义的特性,以避免这种复杂性。

问题回答

Try:

$( #less:concepts-less-css-style )[0].innerHTML

id是, j认为自己是假的挑选者。 审判

var elm = document.getElementById("less:concepts-less-css-style"),
    content = elm.innerHTML || elm.innerText || elm.textContent;

    alert( content );

当然,你可以改变id,不要太不规律,干.。

改用子

  var test = $( style[id=" +my_id+ "] ).text();
    //or
  var test2 = $( style[id="less:concepts-less-css-style"] ).html();




相关问题
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: &...

热门标签