How to make a html box appear on page using JavaScript/JQuery? -
How can I open a square of html with an ID using JS / JQuery?
HTML I want to trigger with JS / JQuery
& lt; Section class = "modal - show" id = "show" tabindex = "- 1" role = "dialog" aria-labelelledby = "label-show" aria-hidden = "true" & gt; & Lt; Div class = "modal-inner" & gt; & Lt; Header & gt; & Lt; H2 id = "label-show" & gt; A Model & lt; / H2 & gt; & Lt; / Header & gt; & Lt; Div class = "modal-content" & gt; & Lt; P & gt; Content & lt; / P & gt; & Lt; Div id = "badgeselect" & gt; & Lt; / Div & gt; & Lt; Footer & gt; & Lt; P & gt; Footer & lt; / P & gt; & Lt; / Footer & gt; & Lt; / Div & gt; & Lt; / Section & gt; I have tried to use
I
$ ('#show'). Dialog ('open');
The only other idea that does not work is that the complete code should also copy an image that the user clicks on ( show
To activate)
I am not the only part at this time, after the user clicks on the image, the above code is making the show on the page.
$ (document) .ready (function () {$ ('. Go img'). Css (('cursor', 'pointer'); $ ('go'). ('Click', 'img', function (e) {$ (this) .wid (100) .hite (100) .appendTo ('#badgeselect'); $ ('# show'). Dialogue ('Open' );}); Sevmeibz (); Returned;});
.dialog
A native method is not available in Javascript. If you want a model
out of the box, then I recommend using a JavaScript library which can be used like this Twitter's bootstrap will be a great option.
To get started: your
& Lt; link rel = "stylesheet" href = "// maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
Include this script after joining jQuery
& lt; script src = "// maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" & Gt; & Lt; / Script & gt;
HTML:
& lt ;! - Model markup - & gt; & Lt; Div class = "modal fade" id = "modal" & gt; & Lt; Div class = "modal-dialog" & gt; & Lt; Div class = "modal-content" & gt; & Lt; Div class = "modal-header" & gt; & Lt; Button type = "button" class = "off" data-discarded = "model" & gt; & Lt; Span aria-hidden = "true" & gt; & Amp; time; & Lt; / Span & gt; & Lt; Span class = "sr -only" & gt; Close & lt; / Span & gt; & Lt; / Button & gt; & Lt; H4 class = "modal-title" & gt; Model title & lt; / H4 & gt; & Lt; / Div & gt; & Lt; Div class = "modal-body" & gt; & Lt; P & gt; A fine body & amp; Hellip; & Lt; / P & gt; & Lt; / Div & gt; & Lt; Div class = "modal-footer" & gt; & Lt; Button type = "button" class = "btn btn-default" data-dismissed = "model" & gt; Close & lt; / Button & gt; & Lt; Button type = "button" class = "btn btn-primary" & gt; Save changes & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - /.modal-content - & gt; & Lt; / Div & gt; & Lt ;! - /.modal-dialog - & gt; & Lt; / Div & gt; & Lt ;! - /.modal - & gt;
To launch the modal
$ ('# modal'). Model ({'show': true});
Update: $ ('. Go'). ('Click', 'img', function (e) {$ (it) .wid (100) .hite (100) .appendTo ('# badgeselect'); $ ('# modal'). Modal ({ 'Show': true});});
Comments
Post a Comment