Perform a case-sensitive search: - Javascript String

Javascript examples for String:search

Description

Perform a case-sensitive search:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  w ww . jav a  2s  . c o m
    var str = "Blue blue red"
    var n = str.search("blue");
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials