最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - expand collapse html field Firefox - Stack Overflow

programmeradmin4浏览0评论

How do I expand/collapse an html field in Firefox? I incorporated a few JavaScript examples from the web, but they only worked in IE. (I'm limited to HTML and JS)

Suggestions are appreciated.

Thanks.

Yes, I would like to show/hide divs and such.

How do I expand/collapse an html field in Firefox? I incorporated a few JavaScript examples from the web, but they only worked in IE. (I'm limited to HTML and JS)

Suggestions are appreciated.

Thanks.

Yes, I would like to show/hide divs and such.

Share Improve this question edited Jan 19, 2009 at 18:08 T.T.T. asked Jan 19, 2009 at 17:43 T.T.T.T.T.T. 34.7k47 gold badges135 silver badges172 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

If your input field has an ID attribute, you can use CSS to style it as needed. I remend using a library like jQuery, but I have provided an example without as well:

  // hiding without jQuery
  document.getElementById('myInput').style.display = 'none'
  // showing without jQuery
  document.getElementById('myInput').style.display = 'block'

  // hiding with jQuery
  $('#myInput').hide()
  // showing with jQuery
  $('#myInput').show()

jQuery: http://jquery.

What you probably want to do is change css property display of the element to "none" to hide the element and change it back to "block" or "inline" to show it again. It can be done with javascript.

If you want a fancy animation, you could use some kind of javascript library which offers different effects (you may want to check out toggle) or ponents (for example Accordion).

I'm afraid I don't understand your question entirely.

First off, what do you mean by 'html field'? Do you mean as in form fields (text boxes, radio controls, etc?). If so, do you mean how do you dynamically resize them? ('Expand/collapse' to me is ambiguous).

If you mean you want to show/hide divs and such, that's much easier using css and javascript. See this example.

发布评论

评论列表(0)

  1. 暂无评论