How To Set Value With Input Text To Get Tag And Set Condition On Text In Jquery
How i can set value to jquery inseted set html code in this question i set value on body link how i can set html code with input text and work like link i write this code
Solution 1:
Do you want set Text box value by jquery?
- $('.in').val('your custom value or text');
Solution 2:
First. For input multiline you need to use <textarea>
Then split string with
("Yourtext").split("Your Seperator",limit_arraysize);
//example
alert(("Howdy! I'm Flowey the flower").split(" ",3));
//That mean you split with " " (1 blank space)
OUTPUT:
[
"Howdy!"
,"I'm"
,"Flowey"
]
Some example below
functionmyFunction() {
var arr = [];
var text = $("textarea").val();
var submit = text.split("\n"); // USE TO split multilinefor (var i = 0; i < submit.length; i++) {
var temp = submit[i].split(",", 2);
arr[i] = {
value: temp[0],
name: temp[1]
};
}
console.log(arr);
}
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><textareatype="text"style="width: 400px;height:200px;"class="in">
25,ok
80,good
90,no</textarea><!--use TEXTAREA instead INPUT for multiline--><br><inputtype="button"value="submit"onclick="myFunction()" />
Post a Comment for "How To Set Value With Input Text To Get Tag And Set Condition On Text In Jquery"