English 中文(简体)
j Query.cs(不适用)
原标题:jQuery.css() not applying to element

最近,我一直试图深入探讨像抽象和功能性方案拟订等先进(对我来说是好的)方案拟订概念。 这导致我实验了轮椅。

我的情况是,通过使用<代码>.cs({})的匿名功能,没有将动态生成的数值适用于某个特定要素。 我认为,与我研究的虚假译文、字面和字面有关。

无论是 Chrome还是FF的 con都没有留下任何错误,因此,我要问专家。

我是一帆风顺的,但并非工作顺利。 我刚刚将把有关资源连接到发展中国家。

这是我用来玩弄/体验和尝试新东西的大厦。

The js file:

当然,一切都可以通过夸张的十字路口找到。

因此,这里指的是:

  1. 在<代码>(窗口)上,,initDOM(

    $(window).load(function(){ //Style Initial Dom Elements initDOM(); });

  2. Inside of initDom(), I attempt to set the top margin in relation to the parent container by calling setElemMargin() and supplying it with the appropriate params.

    setElemMarg("#main-content-one", "#intro-text", "#intro-text", "margin-top");

  3. <代码>ElemMarg(>>> 获取所供应动力的高度,并利用这些动力计算将在<代码>.css(上确定的差额。

    var setElemMarg = function(elem1, elem2, elemTrgt, propName){
    var margH = (getH(elem1) - getH(elem2)) / 2;
    $(elemTrgt).css({propName : margH});
    console.log(elem1, elem2, elemTrgt, propName, margH); }

    var getH = function(elem){ return $(elem).height(); console.log($(elem).height()); }

  4. 将计算差额适用于<代码>margin-top。 (采用上述方法)

    $(elemTrgt).cs({propName:margH});

感谢任何人。 请允许我表示一些建设性的批评。 也许有些人希望你在你担任婚礼的制定者时会这样做。

法 国

最佳回答
问题回答

为什么不尝试使用<代码>$(element).attr(风格,cs_ Values );?

一、导 言 ElemMarg被打在窗户内。 装载活动,然后是 j/dom,不能保证准备就绪。 您需要在文件负荷活动中指定这一职能。





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

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签