Comments (3)
Which example are you referring to? "Line 27" doesn't really help me ;-)
Anyway, I'm guessing that you are looking at an example featuring a form input element, and in the JavaScript we are checking whether the input is empty or not.
input.value = ''
checks whether the input is empty, i.e. if its value is an empty string.
input.value = ' '
on the other hand is checking whether the input value is equal to a single space character, so will fail if it is anything else.
Does that answer your question? If not, please give me some more details, and I will help you further.
All the best.
from learning-area.
"Sorry I forgot to post the code"
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
</head>
<body>
<label for="search">Name : </label>
<input id="search" type="text">
<button>Search</button>
<p></p>
<script>
let input = document.querySelector("input");
let btn = document.querySelector("button");
let para = document.querySelector("p");
btn.addEventListener(`click` , function(){
let val = input.value.toLowerCase();
//console.log(val);'
input.value = "";
input.focus();
let contacts = [`ranjan:12345` , `jan:78906` , `ran:56882`];
for(let i=0 ; i<contacts.length ; i++){
let contact = contacts[i];
//console.log(contact);
let split_it = contact.split(":");
//console.log(split_it);
if(val === split_it[0].toLowerCase()){
para.textContent = `So, you're looking for ${split_it[0]} of ${split_it[1]}`;
break;
}
else{
para.textContent = `Sorry, couldn't find the result`;
}
}
});
</script>
</body>
</html>
input.value = ""; (is the line) . And now I'm clear by our explanation, It was really helpful, Thank you.
from learning-area.
Good, glad it helped ;-)
from learning-area.
Related Issues (20)
- div element missing from cool-information-box-start HOT 1
- MDN Learning Area
- https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/JavaScript#using_bad_browser_sniffing_code HOT 1
- Why file created in tmp folder HOT 1
- Form example looks ugly. HOT 7
- oojs.html example shows HTML0204 lint warning HOT 5
- Learning area
- Left sidebar doesn't show scrollbar at specific font sizes. HOT 1
- html/forms/html-form-structure/payment-form.html STYLING ISSUE HOT 3
- Guides > Tools and testing > Cross browser testing > Handling common HTML and CSS problems (Issue)
- [revise] fix payment form code snippet HOT 1
- [type="number"]
- Test your skills: Advanced HTML text — Task 2, paragraph 2: Copy discrepancy HOT 19
- Error Message is Cut Off at the Top when the Example is at the Bottom of the Browser Window HOT 10
- javascript/introduction-to-js-1/first-splash/number-guessing-game.html line 64 is different than any material covered by the tutorial HOT 3
- Standardize lang attribute usage in HTML tutorial on MDN to 'en-US' or 'en-us' HOT 3
- Auto-generated method stub
- Auto-generated method stub
- Width capped at 90% and height capped at 160px in javascript/building-blocks/tasks/styles.css HOT 3
- Label is covered by Text Area in learning-area/html/forms/your-first-HTML-form/first-form-styled.html
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learning-area.