jquery - if else if statement on mousedown event -
My goal is to display a different dialog box to click on each item I currently have a setup and I thought That's just if I can add the statement. If div_a, dialog_a on moussudown, div_b, dialog_b, etc mussudown etc ... i am new to coding and can not understand it once.
Here is my code for dialog:
$ (document) .ready (function () {$ ("# questiona"). Masudown (function () { $ ("# Dialoga"). Dialog ();});});
Since you are new to coding, I want to use the jQuery team's jQueryUI library I recommend - which includes a .dialog () capability (they are called "widgets"). How it works: (1) your & lt; Head & gt; & Lt; / Head & gt; Include jQuery's and jQueryUI libraries. Note that you must also include a suitable CSS Theme Library for jQueryUI (or the dialog will disappear): & Lt; Script src = "// ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> (2) Create an empty div in your HTML, and start it as a dialog: HTML:
& lt; Div id = "myDlg" & gt; & Lt; / Div & gt; jquery:
$ ('# myDlg'). Dialog ({autoOpen: incorrect, model: true, width: 500, height: 'auto'}); (3) Then, when you are ready to display the dialog, new data in the myDlg div before opening Insert dialog: $ ('# myDlg'). Html ('& lt; div & gt; This will appear in the dialog & lt; / div & gt;'); . $ ('# MyDlg') dialog ('open'); The above allows you to change the contents of the dialog and use the same dialog DIV every time.
What will be the example of work like:
HTML: & lt; Div id = "myDlg" & gt; & Lt; / Div & gt; & Lt; div id = "questiona" class = "allques" & gt; & Lt; div class = "question" & gt; What is 2 + 2? & Lt; / Div & gt; & Lt; Div class = "answer" & gt; 4 & lt; / Div & gt; & Lt; / Div & gt; & Lt; div id = "questionb" class = "allques" & gt; & Lt; Div class = "question" & gt; What is the 12th Imam? & Lt; / Div & gt; & Lt; Div class = "answer" & gt; Completely unique reason that Iran wants nuclear bombs & Lt; / Div & gt; & Lt; / Div & gt; jQuery: var que, ans; $ ('# MyDlg'). Dialog ({autoOpen: wrong, model: true, width: 500, height: 'auto', button: {"see answer": function () {$ ('# myDlg'). Html ('.') ($. ('.i-dialog-buttonset'). Next ('button') Hide ();}, "close": function () {$ ('# myDlg'). Html ('') .dialog (' Close ');}}}) $ ('. Allques') click (function () {que = $ (this) .find ('. Question'). Html (); ans = $ (this) .Find ('. Answer') .HTML); $ ('# MyDlg') .html (que) .dialog ('Open');});
Resources:
Comments
Post a Comment