Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Chaining is generally done on the basis of the object that a method should return. If <code>object A</code> be an instance of <code>class A</code> and a method in it returns <code>object A</code> then the returned object can again be applied to the same class and this can be arranged in a chaining fashion. Or say object of <code>class A</code> returns object of <code>class B</code> then, the returned object can be applied to the method of <code>class B</code>.</p> <pre><code>objectOfA-&gt;methodOfA(arg)-&gt;methodOfB(args); </code></pre> <p>In this case if <code>objectOfA-&gt;methodOfA(arg)</code> returns object of <code>class B</code> and hence the method of <code>class B</code> can be called upon it and chained as above.</p> <p>In your case,</p> <pre><code>$('div.selected').html('Blah ..') </code></pre> <p>Here <code>$('div.selected')</code> return a jquery element object(or array of object); upon which the method <code>.html()</code> can be applied since the method is only applicable to element object of jquery. It is just chaining as other programming languages do.</p> <p>In case of PHP this case looks like,</p> <pre><code>$class-&gt;method1(argument)-&gt;method(2) </code></pre> <p>In this case, if class A has two methods method1 and method2 and method1 return the instance of its own then method 2 is again applicable to it. </p> <p>This can be related to a function as well. Lets us suppose I have a function as such;</p> <pre><code>def function1(name): return name def function2(arg): print len(name) </code></pre> <p>Now, this two functions can be chained simply as,</p> <pre><code>function2(function1('My Name is blah ...')) </code></pre> <p>Since the function1 returns a value, the type of the value must match to the input argument of function2 and this is how object work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload