Jquery

Jquery

Subjects

Latest Asked Question

A : hello; Answer: Use the jQuery attr() method for example: $('div2[data-id="230"]').addClass('error'); $('div2[data-id="230"]').append('<div id="450" class="success">Added</div>'); $('div2[data-id="230"]').removeAttr('data-id'); hope its use full to you
45 Likes
A : <!doctype html> <html lang = "en">    <head>       <meta charset = "utf-8">       <title>jQuery UI Autocomplete functionality</title>       <link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"          rel = "stylesheet">       <script src = "https://code.jquery.com/jquery-1.10.2.js"></script>       <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>              <style>          #project-label {             display: block;             font-weight: bold;             margin-bottom: 1em;          }          #project-icon {             float: left;             height: 32px;             width: 32px;          }          #project-description {             margin: 0;             padding: 0;          }       </style>              <!-- Javascript -->       <script>          $(function() {             var projects = [                {                   value: "java",                   label: "Java",                   desc: "write once run anywhere",                },                {                   value: "jquery-ui",                   label: "jQuery UI",                   desc: "the official user interface library for jQuery",                },                {                   value: "Bootstrap",                   label: "Twitter Bootstrap",                   desc: "popular front end frameworks ",                }             ];             $( "#project" ).autocomplete({                minLength: 0,                source: projects,                focus: function( event, ui ) {                   $( "#project" ).val( ui.item.label );                      return false;                },                select: function( event, ui ) {                   $( "#project" ).val( ui.item.label );                   $( "#project-id" ).val( ui.item.value );                   $( "#project-description" ).html( ui.item.desc );                   return false;                }             })                              .data( "ui-autocomplete" )._renderItem = function( ul, item ) {                return $( "<li>" )                .append( "<a>" + item.label + "<br>" + item.desc + "</a><xmp>" )                .appendTo( ul );             };          });       </script>    </head>        <body>       <div id = "project-label">Select a project (type "a" for a start):</div>       <input id = "project">       <input type = "hidden" id = "project-id">       <p id = "project-description">    </body> </html>
45 Likes
A : Use this code fully tested and workable.    <ul>                     <li>Name</li>                     <li>Price</li>                   </ul>   <ul class="products-grid"> <li data-position="potatoes" data-price="10" class="class item col-lg-4 col-md-3 col-sm-4 col-xs-6"></li> <li data-position="apple" data-price="20" class="class item col-lg-4 col-md-3 col-sm-4 col-xs-6"></li> </ul> function sorbyname() {   $(".products-grid .class").sort(sort_li).appendTo('.products-grid');   function sort_li(a, b) {     return ($(b).data('position')) < ($(a).data('position')) ? 1 : -1;   } }   function sorbyprice() {   $(".products-grid .class").sort(sort_li).appendTo('.products-grid');   function sort_li(a, b) {     return ($(b).data('price')) < ($(a).data('price')) ? 1 : -1;   } }  
45 Likes
A : Hi here is the code: $('#myForm input').on('change', function() { alert($('input[name=radioName]:checked', '#myForm').val()); }); In this code on selecting radio button, you get alert with selected radio button value.
45 Likes
A : Hi there is no need of jquery to reload current page, use can just use javascript code.. <script> location.reload(); </script>
45 Likes
A : $('#id1 option[value="'+id+'"]').prop('selected', true);
45 Likes
A : Use this statement, it will help you $('#id1').trigger('change');
45 Likes
Jquery Related Topic's