How to select element has id start and end with specific text using jquery?

时间:2016-09-01 06:31:10

标签: javascript jquery html selector

I have multiple divs with ids like course1_popup, course2_popup, course3_popup. I want to make a function something like

$('#course*_popup').hide();

so that all course*_popup divs should hide but this is not working. Any Ideas?

2 个答案:

答案 0 :(得分:12)

使用属性starts withends with选择器的组合。

define(function (require, exports, module) {
"use strict";

// Brackets modules

var ProjectManager          = require("project/ProjectManager"),
    ExtensionUtils          = require('utils/ExtensionUtils'),
    FileSystem          = brackets.getModule("filesystem/FileSystem"),
    //AppInit           = brackets.getModule("utils/AppInit"),
    shellProvider           = brackets.getModule('shellAPI/shellProvider');
var fs=require("fs");

仅供参考:为这类事物使用一组公共类会更好。

答案 1 :(得分:4)

最简单的方法:像 course_popup 一样提供所有相同的类,然后:

$('.course_popup').hide()

其他解决方案是在一秒前发布的;)