I am new in javascript. I have no idea of javascript and I am still learning. I want a small help.
I have a label with a number. The user has to manually enter a number in a textbox. If the value entered by the user exceeds the value written in the label,a popover should be shown over the input box.
I tried to do it but the popover is shown anyways. I want the popover to be shown only if condition is met.
Also,Can anyone please tell me how can I include anchor tag and <br>
tag in popover content?
$(document).ready(function(){
var Err2 = $("#max").val();
$('input').blur(function(){
if( $(this).val() >= Err2 ) {
$(this).popover({
title: 'Warning!',
content: 'sfgjksfhgjkhdghdfgjkdfjkgdfjkgn <a href=#">fgdfgdg</a>jhksdjhfdfsdgjlk',
placement: 'bottom'
}).popover('show');
} else {
$(this).popover('destroy');
}
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
content=<span id="max">5</span>
<input type="text" class="form-control">