我一直在研究这个简单的搜索框来搜索表中的名称,我已经成功了,现在我一直在研究很多关于如何使这个搜索框容易受到攻击的内容(这是我正在做的一门课程要求) )。
当我输入时,<script>alert("boom!");</script>我的页面上会发出警报,但在我当前的代码中,它并没有真正做到这一点,我也不知道为什么,因为我使用jquery?
如果有人能看一下我的代码并使这段代码容易受到攻击,我将不胜感激:)
这是我的代码:
$(document).ready(function(){
$('#search').on('click', function(){
var term = $('#term').val().toLowerCase();
$.each(list,function(index,value){
var count = arrayInArray(term,list[index]);
console.log(count);
$("tr:eq(" + (count + 1) + ") td").each(function(){
var tb = [];
tb.push($(this).text());
console.log(tb); // data to be printed somewhere
});
});
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="input-group">
<input id="term" type="text" class="form-control" placeholder="Search Participant...">
<span class="input-group-btn">
<button id="search" class="btn btn-default" type="button">Search</button>
</span>
</div>Run Code Online (Sandbox Code Playgroud)