Use Of :not(), :not, :nth-child()
Note that since JavaScript arrays use 0-based indexing, these selectors reflect that fact. This is why
ecause jQuery's implementation of
https://api.jquery.com/nth-child-selector/
https://api.jquery.com/eq-selector/
$("#table4 tr:not(:last,:first,#table4-first-tr, :nth-child(2) )").remove();
Note that since JavaScript arrays use 0-based indexing, these selectors reflect that fact. This is why
$( ".myclass:eq(1)" )
selects the second element in the document with the class myclass, rather than the first. In contrast, :nth-child(n)
uses 1-based indexing to conform to the CSS specification.ecause jQuery's implementation of
:nth-
selectors is strictly derived from the CSS specification, the value of n
is "1-indexed", meaning that the counting starts at 1. For other selector expressions such as :eq()
or :even
jQuery follows JavaScript's "0-indexed" counting. Given a single <ul>
containing two <li>
s, $( "li:nth-child(1)" )
selects the first <li>
while $( "li:eq(1)" )
selects the second.https://api.jquery.com/nth-child-selector/
https://api.jquery.com/eq-selector/
$("#table4 tr:not(:last,:first,#table4-first-tr, :nth-child(2) )").remove();
Check If A Checkbox Is Checked With jQuery
// Trigger checkbox click on it's parent click
- $("body").on("click", ".checkbox-td", function (event) {
- debugger;
- $(':checkbox', this).trigger('click');
- event.stopPropagation();
- });
If checkbox is checked or not
- if (jQuery(this).is(':checked')) { }
- else if (jQuery(this).is(':not(:checked)')) { }
When testing local server ajax was working fine. But when put in http://192.168.153.253/ERP/ ajax wasn't working.
get that ERP was added and for the shake a base url is needed.
jQuery track when #Mymodal is colosed
#Remove checkbox with delay one by one: First one work. If I put check box in setTimeout then it will refer $(this) = wind function and checkbox aren't removed
get that ERP was added and for the shake a base url is needed.
- <script type="text/javascript">
- var base = '@Url.Content("~/")';
- </script>
jQuery track when #Mymodal is colosed
- $('#myModal').on('hidden.bs.modal', function (e) {})
- jQuery Delaying While Removing/Adding CSS
- setTimeout(function () {
- ClickedTd.css("border", "0px solid green");
- }, 2000);
#Remove checkbox with delay one by one: First one work. If I put check box in setTimeout then it will refer $(this) = wind function and checkbox aren't removed
- var i = 0;
- $(".checkbox-td .ckbox:checkbox:not(:disabled)").each(function () {
- i++;
- var chkbox = $(this);
- setTimeout(function () {
- chkbox.remove();
- }, 1000 - 100 * i);
- });
- i = 0;
- $(".checkbox-td .ckbox:checkbox:not(:disabled)").each(function () {
- i++;
- setTimeout(function () {
- $(this).remove();
- }, 1000 - 100 * i);
- });
# Juquery $.Ajax Jquery Ajax Method with object variable as data
- //dyes_forecasting.ForecastingHead = dyes_forecasting_head_list;
- //dyes_forecasting.DyesRecipe = dyes_recipe_list;
- //var data = "{'model':" + JSON.stringify(dyes_forecasting) + "}";
- function LoadList() {
- var jdata = PrepearJasonData('filter-item');
- //alert(JSON.stringify(jdata));
- WaitMeStart();
- $.ajax({
- type: 'POST',
- url: '/tablessetup/List',
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(jdata),
- // data: JSON.stringify({ "Ldno": Ldno }),
- success: function (data) {
- $('#content-box').html(data);
- InitForm();
- InitSortingHeader("content-box");
- },
- error: function (e) {
- //alert(e.responseText);
- WaitMeStop();
- // l.stop();
- alertify.error("Something technical error occurred");
- }
- }).done(function () {
- WaitMeStop();
- // l.stop();
- });
- }
- $.ajax({
- type: 'POST',
- url: base + "Chemical/SearchOrderDetails",
- contentType: "application/json; charset=utf-8",
- //data: JSON.stringify(jdata),
- //data: JSON.stringify({ "Ldno": Ldno }),
- success: function (data) {
- if (data.indexOf("No record was found") >= 0) {
- IaoCustomizedMessage(data.toString(), "warning", "dark", true, 2500);
- $("#grid").append("<tr><td colspan='12'>" + data + "</tr></td>");
- }
- else {
- $("#grid").append(data);
- ProcesDyesRecipePercantageTableDivVisibility("show");
- }
- },
- error: function (error) {
- if (typeof error.message == "undefined") {
- var element = $(error.responseText);
- var message = element.get(1).innerText;
- IaoCustomizedMessage(message, "error", "dark", true, 8000);
- }
- else IaoCustomizedMessage(e.message, "error", "dark", true, 5500);
- }
- }).done(function () {
- IaoCustomizedMessage("Successfully retrieve data from server", "success", true, 1500);
- });
Juquery $.Ajax Jquery Ajax Method with variable as data For Php Page
- $("body").on("change", "#buyer", function() {
- console.log("Allahu Akbor");
- var buyer = $("#buyer").val().trim();
- var order = $("#order").val().trim();
- $.ajax({
- type: 'GET',
- url: 'GetOrderList.php',
- contentType: "application/json; charset=utf-8",
- data: { buyer : buyer, order : order } ,
- success: function (data) {
- $('#message').html(data);
- },
- error: function (e) {
- }
- }).done(function () {
- console.log("Alhamdulilla");
- });
- });
Iao Customized Message
- IaoCustomizedMessage(data.toString(), "warning", "dark", true, 2500);
- <link href="@Url.Content("~/Bootstrap/iao-alert.css?_" + DateTime.Now.Ticks)" rel="Stylesheet" />
- <script src="@Url.Content("~/Bootstrap/iao-alert.jquery.js?v=" + 1.1)"></script>
- function IaoCustomizedMessage(msg, type, mode, autoHide, alertTime) { // By Muhammad Ashikuzzaman in 2018.10.06
- if (typeof type == "undefined" || type === "") {
- type = "notification";
- } if (typeof autoHide == "undefined" || autoHide === "") {
- autoHide = true;
- }
- if (typeof alertTime == "undefined" || alertTime === "") {
- // alertTime = 3000;
- }
- if (typeof mode == "undefined" || mode === "") {
- mode = "dark";
- }
- $.iaoAlert({
- // default message
- msg: msg,
- // or 'success', 'error', 'warning'
- type: type, //"notification",
- // or light dark
- mode: mode,
- // auto hide true, false
- //// autoHide: true,
- autoHide: autoHide,
- // fade animation speed
- fadeTime: "2800",
- // timeout in milliseconds
- alertTime: alertTime,
- // shows close button
- closeButton: true,
- // close on click
- closeOnClick: true,
- // custom position
- position: 'bottom-right',
- // fade on hover
- fadeOnHover: true,
- // z-index
- zIndex: '999',
- // additional CSS class(es)
- alertClass: ''
- });
- }
Data Table Related Code Snippet :
Reload Datatable after ajax success
- $('body #quality_control_table').dataTable().fnDestroy();
Detect Shift + Enter key Press or Ctrl + Enter Key Press Or Any key Press
- $(document).keydown(function (e) {
- if (e.keyCode == 13 && !e.shiftKey) { // If shiftKey + ENter is hit
- debugger;
- console.log("Only Enter Press");
- e.preventDefault();
- }
- else if (e.keyCode == 13 && e.shiftKey) { // If shiftKey + ENter is hit
- debugger;
- console.log("Shift Entered Pressed");
- }
- });
- $("body").on("keydown", ".AfterHeatSetInfo", function (e) {
- if (e.keyCode == 13 && !e.shiftKey) { // If shiftKey + ENter is hit
- debugger;
- console.log("Only Enter Press");
- e.preventDefault();
- }
- else if (e.keyCode == 13 && e.shiftKey) { // If shiftKey + ENter is hit
- debugger;
- console.log("Shift Entered Pressed");
- }
- });
No comments:
Post a Comment