Home > Javascript, Program > JQuery – substring some keyword

JQuery – substring some keyword

March 21st, 2012

substring some keyword

var keyword = ‘abc’;

var index = ($(“#content”).val().indexOf(keyword));

if(index != -1){
var pre = $(“#content”).val().substring(0, index);
var pos = $(“#content”).val().substring(index+keyword.length);

$(“#content”).val(pre+pos);
}

Javascript, Program , , ,

  1. No comments yet.
  1. No trackbacks yet.
*