Simple way to get days between 2 dates...
Tuesday, September 21, 2021
Tuesday, August 17, 2021
Cheat Sheet - CSS, JQuery Selectors and Filters
* | All elements. |
element | Basic selector defined by the elements name. IE – the <p> tag. |
.class | Elements specified by a specific class attribute. |
#id | Elements specified by the specific ID number. |
selector1, selector2 | Elements that match more than one selector. |
:first | First element from the selection. |
:last | Last element from the selection. |
:even | Even index selection. |
:odd | Odd index selection. |
:not(selector) | Everything except the selector in parentheses. |
:eq() | Elements with an index number equal to the parameter. |
:gt() | Elements with an index number greater than the parameter. |
:lt() | Elements with an index number less than the parameter. |
:header | All h1 – h6 HTML tags. |
:animated | Any element being animated. |
:focus | The element which has focus (an input item such as a field, checkbox, button, or link). |
:empty | Elements with no children. |
:parent | Elements that have a child node. |
:has(selector) | Elements contain atleast one of the elements that match the selector in parentheses. |
:contains(‘text’) | Elements that contain the specified text in parentheses. |
:hidden | Elements that are hidden. |
:visible | Elements that exist and take up space in the layout of the page. |
:nth-child(exp) | Elements that match the mathematical pattern. IE – div :nth-child(2+1) |
:first-child | First child from the current selection. |
:last-child | Last child from the current selection. |
:only-child | The only existing child of the matching element. |
[attribute] | Elements that have the specified attribute value – IE – [name^ = “value”] |
:input | Elements with input. |
:text | Elements with text. |
:password | Elements with password inputs. |
:radio | Elements with radio buttons. |
:checkbox | Elements with checkboxes. |
:submit | Elements with submit buttons. |
:image | Elements with images. |
:reset | Elements with reset buttons. |
:button | All buttons. |
:file | Elements with file inputs. |
:selected | All items from drop-down lists. |
:enabled | All enables elements, including defaults. |
:disabled | All disables elements. |
:checked | All checked checkboxes or radio buttons. |
If there’s anything that I’ve missed or more explanation that you’d like to see, feel free to leave a comment.
Help other's to help yourself !!
Wednesday, May 5, 2021
Export HTML table to Excel file
<!-- https://github.com/linways/table-to-excel -->
<script src="https://cdn.jsdelivr.net/gh/linways/table-to-excel@v1.0.4/dist/tableToExcel.js"></script>
function exportReportToExcel(c) {
let table = $("#feedbackExport2Excel"); // you can use document.getElementById('tableId') as well by providing id to the table tag
let fileName = "Feedback";
TableToExcel.convert(table[0], { // html code may contain multiple tables so here we are refering to 1st table tag
name: `${fileName}.xlsx`, // fileName you could use any name
sheet: {
name: 'Sheet 1' // sheetName
}
});
}//exportReportToExcel
Wednesday, February 3, 2021
Simple way to find Index value from JSON Array
Simple way to find Index value from JSON Array
var data = [{"name":"placeHolder","section":"right"},{"name":"Overview","section":"left"},{"name":"ByFunction","section":"left"},{"name":"Time","section":"left"},{"name":"allFit","section":"left"},{"name":"allbMatches","section":"left"},{"name":"allOffers","section":"left"},{"name":"allInterests","section":"left"},{"name":"allResponses","section":"left"},{"name":"divChanged","section":"right"}];
var index = data.findIndex(obj => obj.name=="allInterests");
console.log(index);
Tuesday, February 2, 2021
Add days to a Date using JavaScript
Many times I have face this issue, and hope you too.. this is simple 3 line of code will help and fix this problem.
let days =7 ; // we are going to add 7 days to a date
let cdt = new Date('2021-01-10'); // your date value
let tdt = cdt.setTime(cdt.getTime() + (days * 24 * 60 * 60 * 1000)); // calculation for adding 7 days and adding to time
let targetDT = new Date(tdt).format("yyyy-MM-dd"); // converting back from time to date
Thursday, January 28, 2021
JavaScript to get index from a JSON object with value
In modern browsers you can use findIndex:
But this function is not supported by even not so old versions of a few browser as well as in IE (EDGE supports it). So below is a workaround using javascript: You can use either Array.forEach or Array.find or Array.filter
This method takes little more overhead as it loops through the whole object to search for the match. So, for lengthy JSON data, this method is not suggested(even though it gets the work done).