English 中文(简体)
添加另一类:
原标题:Add another class to a div
  • 时间:2010-04-29 18:09:04
  •  标签:
  • javascript

我的职能是检查提交表格的年龄,然后根据年龄将新内容退回。 现在,我刚刚用完了。 替换超文本内容。 我认为,如果我也能够把一个班子加到一个小区,那么我会更好地为我工作。 例如,我有。

if (under certain age) {
    document.getElementById( hello ).innerHTML = "<p>Good Bye</p>"; 
    createCookie( age , not13 ,0)
    return false;
} else {
    document.getElementById( hello ).innerHTML = "<p>Hello</p>";  
    return true;
}

我想做的是,如果返回不实,那就消失了,被其他内容取代。 我能够以完全的贾瓦里文来看待这一问题。 我不想为这一特殊职能而利用 j。

最佳回答

如果该要素没有等级,则可以划出。 否则,将给一个新的类别Name之后的空间:

  var el = document.getElementById( hello );
  if(el) {
    el.className += el.className ?   someClass  :  someClass ;
  }
问题回答

仅需要使用<代码>文件.getElementById( hello ).setAttribute(类别,某些类别);。

此外,<条码>内午线可产生意外结果! 考虑如下:

var myParag = document.createElement( p );

if(under certain age)
{
    myParag.text="Good Bye";
    createCookie( age ,  not13 , 0);
    return false;
{
else
{
    myParag.text="Hello";
    return true;
}

document.getElementById( hello ).appendChild(myParag);

在OMS,一个元素的类别只是一个空间分离的每个类别。 你们只是需要执行平级逻辑,以插入/删除作为必要条件的类别。

我想问的是,为什么要你使用 j子? 这使这种问题变得十分容易。

I am facing the same issue. If parent element is hidden then after showing the element chosen drop down are not showing. This is not a perfect solution but it solved my issue. After showing the element you can use following code.

function onshowelement() { $( .chosen ).chosen( destroy ); $(".chosen").chosen({ width:  100%  }); }




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

热门标签