Một Số Câu Lệnh Jquery Thường Dùng - FCWordpress
Có thể bạn quan tâm
Một số câu lệnh jquery thường dùng
Các bài viết khác có thể hữu ích với bạn
Gửi Phản Hồi Chọn đánh giá của bạn Gửi 0 Bình Luận Thông tin người gửi Anh Chị Gửi bình luận
28/06/2019 08:08 4980
1.Show và hide một thành phần
Cái này áp dụng khi anh chị cần show hoặc hide một element nào đó

| 123 | $('#rich_snippet_pro_article_enable').change(function(){$('.article-bottom').toggle(this.checked)}).change() |
mã html
<input name="rich_snippet_pro[article_enable]" id="rich_snippet_pro_article_enable" type="checkbox" value="1" > </div> </div> </div> <div class="article-bottom"> Thành phần để show hoặc hide </div>| 1234567 | <input name="rich_snippet_pro[article_enable]"id="rich_snippet_pro_article_enable"type="checkbox"value="1"></div></div></div><div class="article-bottom">Thành phầnđểshow hoặchide</div> |
2.Show và hide qua select
$('#rich_snippet_pro_organization_logo').change(function(){ console.log($(this).val()); if($(this).val() == 2){ $('.rich_snippet_pro_organization_logo_upload').show(); }else{ $('.rich_snippet_pro_organization_logo_upload').hide(); } }).change();| 12345678 | $('#rich_snippet_pro_organization_logo').change(function(){console.log($(this).val());if($(this).val()==2){$('.rich_snippet_pro_organization_logo_upload').show();}else{$('.rich_snippet_pro_organization_logo_upload').hide();}}).change(); |
3. Ajax wordpress
$(document).on('mouseleave','.rich-snippets-pro-star-rating-wrap',function(e){ var submit_data = { 'action': 'rich_snippets_pro_rating_mouse_leave', 'post_id': $('.rich-snippets-pro-out').data('post_id'), }; //console.log(submit_data); $.ajax({ type: 'POST', url: richsnippetpro_vars.ajax_url, data: submit_data, success: function ( response ) { //console.log(response); if ( 'success' == response.status ) { $('.rich-snippets-pro-star-rating-wrap').html(response.rating_star); $('.rich-snippets-pro-summary-wrap').html(response.rating_summary); } else { } }, error: function( e ) { } }); });| 123456789101112131415161718192021222324 | $(document).on('mouseleave','.rich-snippets-pro-star-rating-wrap',function(e){varsubmit_data={'action':'rich_snippets_pro_rating_mouse_leave','post_id':$('.rich-snippets-pro-out').data('post_id'),};//console.log(submit_data);$.ajax({type:'POST',url:richsnippetpro_vars.ajax_url,data:submit_data,success:function(response){//console.log(response);if('success'==response.status){$('.rich-snippets-pro-star-rating-wrap').html(response.rating_star);$('.rich-snippets-pro-summary-wrap').html(response.rating_summary);}else{}},error:function(e){}});}); |
4.Chặn event mặc định
e.preventDefault();| 1 | e.preventDefault(); |
- Làm sticky sidebar đơn giản (simple sticky sidebar)
- Kiểm tra số điện thoại bằng javascript ( check phone number by javascript)
- Function kiểm tra email bằng javascript ( Function check email by javascript)
- Thực hiện một function tại một thời điểm nào đó trong javascript (setInterval và setTimeout)
- Check tất cả checkbox bằng javascript
- Show và hide một element bở select form
- Scroll to with animation to element by jquery
- Tìm kiếm tức thời autocomplete hay đề xuất trong javascript
- Xử lý ngày tháng date trong javascript
- Đoạn mã copy text tới clipboard
5.Get value của tinyMCE
var message = tinyMCE.activeEditor.getContent();| 1 | varmessage=tinyMCE.activeEditor.getContent(); |
6.Redirect tới một url
window.location.href = url_search;| 1 | window.location.href=url_search; |
7.Hiệu ứng loading
Pulling...| 1 | Pulling... |
8.Scroll tới một element id
$('html, body').animate({ scrollTop: $("#agency_information_out").offset().top }, 1000);| 123 | $('html, body').animate({scrollTop:$("#agency_information_out").offset().top},1000); |
8.Reload trang hiện tại
location.reload();| 1 | location.reload(); |
9. input check only select one at one time
$('.vaydep_filter_custom').click(function() { $('.vaydep_filter_custom').not(this).prop('checked', false); });| 123 | $('.vaydep_filter_custom').click(function(){$('.vaydep_filter_custom').not(this).prop('checked',false);}); |
10. ajax cơ bản (basic ajax)
var submit_data = { action: 'request_data_import', cat_id: cat_id }; $.ajax({ type: 'POST', url: '<?php echo admin_url('admin-ajax.php'); ?>', //url: kitimportelementor_vars.ajax_url, data: submit_data, success: function ( response ) { if ( 'success' == response.status ) { } } });| 1234567891011121314151617 | varsubmit_data={action:'request_data_import',cat_id:cat_id};$.ajax({type:'POST',url:'<?phpechoadmin_url('admin-ajax.php');?>',//url: kitimportelementor_vars.ajax_url, data:submit_data,success:function(response){if('success'==response.status){}}}); |
có thể bạn cần xem:
- Cách dùng Local Storage để lưu trữ dữ liệu ít quan trong [ 09/11/2022 01:39 ]
- Mã js copy nội dung text của một element vào bộ nhớ tạm [ 19/01/2022 14:42 ]
- Đoạn mã copy text tới clipboard [ 14/11/2021 04:00 ]
- Xử lý ngày tháng date trong javascript [ 30/10/2021 02:30 ]
- Tìm kiếm tức thời autocomplete hay đề xuất trong javascript [ 21/10/2021 02:51 ]
- Scroll to with animation to element by jquery [ 08/09/2021 02:02 ]
- Show và hide một element bở select form [ 24/07/2021 07:31 ]
- Check tất cả checkbox bằng javascript [ 11/11/2020 08:18 ]
- Thực hiện một function tại một thời điểm nào đó trong javascript (setInterval và setTimeout) [ 15/10/2020 13:20 ]
- Function kiểm tra email bằng javascript ( Function check email by javascript) [ 20/08/2020 04:36 ]
Từ khóa » Câu Lệnh Val Trong Jquery
-
.val() | Hàm JQuery | Tham Khảo JQuery | Học Web Chuẩn
-
Phương Thức Val() Trong JQuery | Lấy Giá Trị Thuộc Tính Value Của ...
-
.val() Trong JQuery - Hoclaptrinh
-
JQuery: Val() Method | V1Study
-
Sự Khác Biệt Giữa Val () Và Text () - HelpEx
-
Jquery .val () + = Thành Ngữ - HelpEx - Trao đổi & Giúp đỡ
-
JQuery Cơ Bản - Viblo
-
JQuery Selector - Viblo
-
.val() | JQuery API Documentation
-
Tài Liệu Tìm Hiểu JQuery Dành Cho Người Mới Bắt đầu - SlideShare
-
Parent Find Input Value Js? How To Get The Parent Element Value ...
-
Code Web Làm Với Jquery Không Chạy - Programming - Dạy Nhau Học
-
JQuery Căn Bản - JQuery Selectors - ThachPham
-
Cách Lấy Giá Trị đã Chọn Trong Hộp Chọn (Select) Bằng JQuery