Sunday 15 June 2014

javascript - how to add content to the specific ul of whose parent li is clicked? -


I would like to add some content, whose parent Lee has been clicked and removed any previous Lee's InertMate Was that clicked? & lt; Html & gt; & Lt; Top & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "testtab.css" /> & Lt; Script type = "text / javascript" src = "script / jquery-1.10.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ ('# Chat ul li a') ('Click', function (e) {warning ("in"); warning ($ (this) .closest ('li'). Index ());}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "chat" category = "chat" & gt; & Lt; Ul class = "chatmenu" & gt; & Lt; Li id = "one" square = "user" & gt; & Lt; A href = "#in" & gt; Abcy & lt; Span class = "notify" & gt; 1 new * & lt; / Span & gt; & Lt; / A & gt; & Lt; Div class = "chattng" & gt; & Lt; Ul class = "overl" & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li id = "two" square = "user" & gt; & Lt; A href = "# two" & gt; AVVV & Lt; Span class = "notify" & gt; A & lt; / Span & gt; & Lt; / A & gt; & Lt; Div class = "chattng" & gt; & Lt; Ul class = "overl" & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li id = "three" square = "user" & gt; & Lt; A href = "# three" & gt; GT & Lt; Span class = "notify" & gt; D & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li id = "four" class = "users" & gt; & Lt; A href = "# four" & gt; Trt & lt; Span class = "notify" & gt; E & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; ; & Lt; Li id = "five" square = "user" & gt; & Lt; A href = "# 5" & gt; KKK Lieutenant; Span category = "notify" & gt; F & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; ; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;

Once it is known how to do it, whatever has been clicked gets the internal HTML and the previous link that was clicked, the inner thumb In the form?

You are using live on that version which is not supported Does Use on .

  $ ('# chat ul li a'). ('Click', function (e) {warning ($ (this) .clostest ('li'). Index ());});   

This ready handler must be wrapped to trigger when the elements within #chat are ready and initialized.

  $ (document) .ready (function () {$ ('# chat ul li a'). ('Click', function (e) {alert ($ (this) Closest ('li'). Index ());});});   

Here's a demo:

Or, you can force this event with the document object:

  $ (document) .on ('click', '#chat ul li a', function (e) {warning ($ (this) .closest ('li'). Index ());});   

This is what live used to do.

Can anyone edit this question? This is the source of this information. We want PPL as per the old information, now what?

No comments:

Post a Comment