parent
do qual inherits
propriedades. Por exemplo, o elemento h3
jQuery Playground
tem o elemento pai de <div class="container-fluid">
, que por sua vez tem o body
pai. jQuery tem uma função chamada parent()
que permite que você acesse o pai do elemento que você selecionou. Aqui está um exemplo de como você usaria a função parent()
se você quisesse dar ao elemento pai do elemento left-well
uma cor de fundo de blue: $("#left-well").parent().css("background-color", "blue")
Forneça ao pai do elemento #target1
uma cor de fundo em vermelho. left-well
deve ter um fundo vermelho.
testString: 'assert($("#left-well").css("background-color") === "red" || $("#left-well").css("background-color") === "rgb(255, 0, 0)" || $("#left-well").css("background-color").toLowerCase() === "#ff0000" || $("#left-well").css("background-color").toLowerCase() === "#f00", "Your left-well
element should have a red background.");'
- text: Você deve usar a função .parent()
para modificar este elemento.
testString: 'assert(code.match(/\.parent\s*\(\s*\)\s*\.css/g), "You should use the .parent()
function to modify this element.");'
- text: 'O método .parent()
deve ser chamado no elemento #target1
.'
testString: 'assert(code.match(/\$\s*?\(\s*?(?:"|")\s*?#target1\s*?(?:"|")\s*?\)\s*?\.parent/gi), "The .parent()
method should be called on the #target1
element.");'
- text: Use apenas o jQuery para adicionar essas classes ao elemento.
testString: 'assert(code.match(/