0

Creating _a.target is a little different.

It like this =>

var _a,_b

var A =function(jquery){

this.target = jquery

}

var B =function(jquery){

this.target =jquery;

_a = new A (this.target)

}

_b = new B($('#id'));

In debugging, _a.target shows right,it is the right $('#id'), but any Jquery method of_a.target is not working!!!!

_a.target.css('color','red') isn't working.

_a.target.offset() return {top:0,left:0}.

but

_a.target.css('color','red') works fine. 

_b.target.offset() return the right value {top:122,left:522.5}.

i just don't know how to deal with it?

anyone can help me out? thank a lot!

  • *"then the `_a.target.css('color','red')` doesn't work!!!!"* Yes, it does; [example](https://jsfiddle.net/31fpmk1u/). Put an [mcve] in the question using Stack Snippets (the `<>` toolbar button), the code you've having trouble with is slightly different from your code above. – T.J. Crowder Aug 14 '16 at 10:34
  • **Now, if people could avoid posting speculative answers to the question, instead waiting until there's a real question here, that would be lovely.** – T.J. Crowder Aug 14 '16 at 10:34
  • Re the edit: [Still works just fine](https://jsfiddle.net/31fpmk1u/1/), both log the same offsets. Again: Put a **runnable** [mcve] using Stack Snippets in the question demonstrating the behavior. – T.J. Crowder Aug 14 '16 at 10:38
  • It's possible you're running into [this issue](http://stackoverflow.com/questions/38660832/element-children-has-elements-but-returns-empty-htmlcollection), but that's a wild guess. – T.J. Crowder Aug 14 '16 at 10:38
  • The real problem i deal with is more complicated. i think i just asked it in a wrong way,hahahah ~ – lm412742171 Aug 14 '16 at 10:42
  • 1
    Thanks T.J. Crowder , i think you just bet on the right issue!!! hahaha~here's your chips! hahahah ~ – lm412742171 Aug 14 '16 at 10:50

0 Answers0