Possible Duplicate:
How can I check the start of a string with jQuery?
我有以下内容:
if ($(this).data('action') == "Editing" || $(this).data('action') == "Create")
{
// how to Check ?
}
如何检查“编辑”或“创建”只是第一个单词而不是完整的字符串?
最佳答案
您可以使用indexOf method检查第一次出现是否位于字符串的开头:
$(this).data('action').indexOf("Editing") == 0
关于jquery - 如何使用 javascript/jQuery 检查字符串开头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9428310/