Posts

Showing posts from 2019

What are some mistakes people make when they start learning HTML, CSS and JavaScript?

Image
Using id instead of class names Many beginners are tending to write CSS using id names instead of CSS class names. We should always aim to reuse the code as much as possible. By using id names we are applying styles only to that particular div rather than sharing the styles which are common to div s having the same class name. Do read this article which gives a practical approach to maintainable CSS . Not using CSS shorthand Using CSS shorthand will come as a second nature by practice. Until then we need to force ourselves to write CSS in the right way. While working on a large project, we will notice that by using shorthand properties the number of code lines in CSS file will be reduced reasonably. CSS Measurements 0px is just a 0. There is no need to mention if it is a px or em. Following a standard measurement throughout the project is important. Be it px or rem, it should be followed by all for the project. Using relative values are encouraged more than absolu

How to show input fields based on dropdown selected options using jQuery

Image
Hide show input fields based on select value Many times, while learning a new technology or a framework, it is not sufficient to read just the documentation and syntax, we need to practice. Many of us may try on our own sometimes things will work out for us sometimes we don't know how to evaluate ourselves. All our recent practice articles were published in that thought of giving readers a practice in jQuery  concepts.  Follow our FB page @CreativeTechnocrayts Other jQuery practice articles 1. jQuery DOM functions and array 2. DOM manipulation in jQuery 3. Daily ui practice - Input range sliders Subscribe to Creative Technocrayts and get updates in front end development and UI / UX. Some of us might run into a problem of  showing input value based on user selecting an option from the dropdown. We can achieve that in many ways.If the user is not selecting a value, the form is incomplete so the user cannot submit the form To check whether the select value is selected us

UI practice #4 Checking whether an element is present using jQuery

Image
How to check whether atleast one input is selected using jQuery Sometimes, while working with forms, a user is expected to select atleast one input, or a feedback should be thrown asking them to "Select atleast one input". How to check that using jQuery When a select option is checked checked attribute is added. To check whether the any of it is checked :checked is used in jQuery. If any of the checkbox is having checked attribute, then the user is allowed to submit. How to check whether an element is present To check whether an element is present, 1) size() function is used 2) .length property is used .length is faster than .size() because, former is a property whereas latter is a function. HTML snippet $('#submitBtn').click(function(){ if($('input[type="checkbox"]:checked').length >= 1){ alert("Is checked"); } else{ alert("Select atleast one"); } }); Other jQuery practice art

UI practice #2 jQuery - DOM functions and array

Image
Creating boxes with repeating background color - jQuery practice This article gives an idea of jQuery and DOM methods and javascript arrays Many of you have tried our previous practice exercise it seems. Jquery array i) When you get an input, you check whether it is validated as a number, ii) Based on the input value, number of boxes is created. iii) Set all the boxes with background colors from an array How to get an input value from textbox var inputValue = $(this).val(); console.log(inputValue); Testing whether the input value is a number For testing whether it is a number, regex pattern is used. if (/^[0-9]$/.test(inputValue)){ console.log("It is a number"); } /^[0-9]$/ :here,[0-9] checks whether it is a number. Note: /^[0-9]{1,2}$/ refers two digits number Creating number of boxes based on input value var section = document.createElement('section'); for (i=0;i<=inputValue-1;i++){ //crea