Menu

Friday, October 1, 2021

Add Event listener on elements(li or multiple values ) using parent element and passing event,"selector" parameter.

HTML

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Practice HTML</title>
    <link rel="stylesheet" href="/Miscellenious/practice.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="/Miscellenious/practice.js"></script>
   
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
    </ul>
  
    
</body>
</html>

Why and when is document.ready() needed

$(document).ready is for assurance full DOM is available at the time the function is called. Any functions and events not depending on the DOM don't need to be put into the ready event.

Well, 

what if we load dom and css first and javascript at the end(just before /body element)

HUUUU.. 

$(document).ready(function(){}); NOT NEEDED

So Check first , In html where is the javascript reference if it's in <head> you must use ready()
but if just before</body> you can skip utilizing ready()

Check it out :

Thursday, September 30, 2021

JavaScript String indexOf()

 

Example

Search a string for "welcome":

let str = "Hello world, welcome to the universe.";
str.indexOf("welcome")   // Returns 13
str.indexOf("Welcome")   // Returns -1

Definition and Usage

The indexOf() method returns the position of the first occurrence of a specified value in a string.

indexOf() returns -1 if the value is not found.

indexOf() is case sensitive.


Visitors that saw a url containing a specific value

 

Create an audience that visited the pages url containing “baby”.

 

if(page.url.indexOf('baby') != -1)

{

 return true;

}

 


Target Server Side implementation using .net SDK

 Target Server Side implementation using .net SDK  This reference guide shows how Adobe Target customers can install, initialize, and use th...