Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have value like below "23*34" i want to get * symbol from that string how can i get and display in div using jquery and html div.


The value not only 23*34 that value may be any length example "2345*3455" or "77*7777" or "1*2" from this type string i want to get * symbol.
Posted
Updated 6-Aug-15 21:20pm
v2
Comments
ZurdoDev 6-Aug-15 8:53am    
Please explain more what you are trying to do.

1 solution

//Try the following code



<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#click").click(function(){
       var divContent = $('#field').text(); 
      var res = divContent.substring(2,3);
      $("#display").text(res);
        alert(res );
    });
});
</script>
</head>
<body>

<div id="field">23*34</div><br>
<div id="display"></div><br>
<button id="click">click for value</button >
</body>
</html>
 
Share this answer
 
v2
Comments
DGKumar 7-Aug-15 3:19am    
The value not only 23*34 that value may be any length example "2345*3455" or "77*7777" or "1*2" from this type string i want to get * symbol.
[no name] 7-Aug-15 4:44am    
<html>
<body>

<button >Try it</button>

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

<script>
function myFunction() {
var str = "HELLOW * ORLD";

var myString = str.indexOf("*")
alert(myString);
var res = str.charAt(myString)
document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>
[no name] 7-Aug-15 4:45am    
Try above code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900