Reputation: 1468
$( document ).ready(){
const filePath = window.top.$('#FilePath').val();
if ("#FilePath:contains('content')") {
alert("content is here")
}
)};
<div id="filePath">content</div>
This is probably really easy but I am trying to alert a message if the filepath div contains a specific word. I looked at various setups and this was the closest I can get, please inform me on what I am doing wrong.
Upvotes: 0
Views: 410
Reputation: 34168
Several errors,
.val()
but does have .text()
$(function() {
form$(function() {
const filePath = $('#filePath').text();
if (filePath.includes('content')) {
alert("content is here");
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="filePath">content</div>
Upvotes: 1