Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7784835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:09:32+00:00 2026-06-01T20:09:32+00:00

code: http://jsfiddle.net/4hV6c/4/ just make any selection, and you’ll get a script error in ie8

  • 0

code: http://jsfiddle.net/4hV6c/4/
just make any selection, and you’ll get a script error in ie8

I’m trying to do this:

$(end_node.parentNode).has(start_node)

which in modern browsers (chrome, ff, opera, etc) returns [] if start_node is not in end_node.parentNode, and returns the element (I forget which) if it is found.

now, end_node is a text element, and the parentNode is an actual DOM entity. IE will perform .has on just $(end_node).has(start_node) but that is obviously different behavior.

Is there a work around to get this to work?

  • in IE the fiddle will error, other browsers will alert you with a boolean value.

UPDATE: here is a word around that overrides .has() for my specific scenario.. not sure if it works for all the cases of .has, as I don’t know them all.
http://jsfiddle.net/8F57r/13/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:09:33+00:00Added an answer on June 1, 2026 at 8:09 pm

    The problem is not jQuery

    Running

    console.log( $("div:has(span)").html() );
    console.log( $("div").has($("span")[0]).html() );
    

    However, the following throws an exception http://jsfiddle.net/mendesjuan/4hV6c/8/

    var textNode =  $("span")[0].childNodes[0];
    $("div").has(textNode);
    

    What that means is that you can’t pass a text node into $.has. You should file a bug with jQuery

    The line that is erroring out is giving the following message

    No such interface supported jquery-1.7.1.js, line 5244 character 3

    That is trying to call the contains method on a node. What that means is that this really is an IE bug that jQuery hasn’t worked around. I’ve reproduced the problem without needing to call $.has http://jsfiddle.net/4hV6c/10/

    // This is broken in IE
    var textNode =  $("span")[0].childNodes[0];
    var divNode = $("div")[0];
    divNode.contains(textNode);
    

    Workaround http://jsfiddle.net/4hV6c/12/

    function contains(outer, inner) {
       var current = inner;
        do {
            if (current == outer) {
               return true;
            }
        } while((current = current.parentNode) != document.body);
    
        return false;
    
    }
    rangy.init();
    
    $(document).bind("mouseup", function() {
        var a = rangy.getSelection();
        start_node = a.anchorNode;
        end_node = a.focusNode;
        var b = a.getRangeAt(0);
        var c = b.commonAncestorContainer;
        b.selectNodeContents(c);
        a.setSingleRange(b);
        alert( contains( end_node.parentNode, start_node) );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code: http://jsfiddle.net/GKBfL/ I am trying to get collection.prototype.add to return a
code: http://jsfiddle.net/xVCrn/1/ (works best in chrome / webkit) I'm trying to get the red
This is my code http://jsfiddle.net/Cfa6c/8/ Basically what I need to do is get the
Here you can see the code: http://jsfiddle.net/LQSK3/1/ I can't get display: inline; working there
Code: http://jsfiddle.net/tRRtY/ <!DOCTYPE HTML> <html> <head> <title>$$ float</title> <script type=text/javascript src=http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default> </script> <style type=text/css>
I am trying to position few elements correctly, here is my code: http://jsfiddle.net/Tjz6D/ Now
I have this code: http://jsfiddle.net/Q4PUw/2/ Hence, a simple HIDDEN TO VISIBLE jQuery Script. What
code: http://jsfiddle.net/WRppV/4/ I should get something like content=> [141, [203, 206, 204, 205], 142,
Just look at my code http://jsfiddle.net/rkumarnirmal/GXAYa/6/ #box_bg is the outer gray box and #box
Here is some code: http://jsfiddle.net/T65E3/3/ I want to get an attr when i know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.