Thanks! That made it work. In the same javascript I managed to create
a div tag in IE with
$("<div>") but maybe there's some other subtlety behind that.


On Apr 2, 10:01 pm, "Karl Rudd" <[EMAIL PROTECTED]> wrote:
> Try making a full formed "a" element, $('<a></a>'). IE is a bit fussy
> sometimes about what it will create, it will fail when you specify an
> "open" element.
>
> Karl Rudd
>
> On Thu, Apr 3, 2008 at 3:47 AM, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
>
> >  I'm going to explain my problem by code. Both of these work perfectly
> >  fine in Firefox but only the *second one* works in IE 6.
>
> >  ** THE ONE I WANTED TO WRITE **
>
> >  function __duplicateToolbarButtons() {
> >    // Make "save" and "save and view" buttons appear in toolbar
> >    if ($('#CMSButtonBar').size() && $
> >  ('input.duplicateintoolbar').size()) {
> >       // Next, make <A> elements then put them into button bar
> >       $('input.duplicateintoolbar').each(function() {
> >          var btn = this;
> >          var a = $("<a>")
> >            .attr('href','#')
> >              .addClass('ButtonAction')
> >                .click(function() {
> >                   btn.click(); return false
> >                })
> >                  .text(btn.value);
>
> >          // insert it just before the last <div> in that area
> >          $('div', $('#CMSButtonBar')).slice(-1).before(a);
>
> >       });
> >    }
> >  }
>
> >  ** THE ONE I HAD TO WRITE **
>
> >  function __duplicateToolbarButtons() {
> >    // Make "save" and "save and view" buttons appear in toolbar
> >    if ($('#CMSButtonBar').size() && $
> >  ('input.duplicateintoolbar').size()) {
> >       // Next, make <A> elements that put them into button bar
> >       $('input.duplicateintoolbar').each(function() {
> >          var btn = this;
>
> >          var a = document.createElement('a');
> >          a.setAttribute('href','#');
> >          a.className='ButtonAction'; //
> >  a.setAttribute('class','ButtonAction') doesn't work
> >          a.onclick=function() {btn.click(); return false};
> >          a.innerHTML=btn.value;
>
> >          // insert it just before the last <div> in that area
> >          $('div', $('#CMSButtonBar')).slice(-1).before(a);
>
> >       });
> >    }
> >  }
>
> >  At first I thought it was something wrong with the way I appended the
> >  created element into the DOM tree but then I added this code just
> >  after the $('<a>')... stuff::
>
> >   alert(a.size());
>
> >  In Firefox it said 1 (as expected) but in IE 6 it said0!! Why?
> >  Are there pitfalls I don't know about in creating elements in IE that
> >  are FAQ?
>
> >  PS. This is jquery-1.2.3.min.js and the piece of junk is IE 6.0 sp2.

Reply via email to